Closed SonyStone closed 8 months ago
Don't use new PGA2D
the internal representation used by this library is a mess. Use PGA2D.fromGanja
instead.
I actually don't know how to use this library to do real GA at the moment. As it stands, this library is just my learning tool to understand what computations go into the geometric product and related operations. All I know is that the unit tests that check for Ganja compatibility pass.
I'll write some examples/tutorials when I understand how these computations are supposed to be applied.
> I don't even know how to create a point in this library
My best guess is PGA2D.fromVector
.
> I don't even know how to create a point in this library My best guess is
PGA2D.fromVector
.
I tried using PGA2D.fromVector, but other operations with it didn't work either.
I tried using PGA2D.fromVector, but other operations with it didn't work either.
I have no idea what points and lines are in PGA yet. Sorry about that. To talk to non-newbies follow the discord link at https://bivector.net/
I highly recommend using ganja.js
before this library hits a v1.0.0
release.
I think the coffeeshop example is using a pre 2.0 version of A Guided Tour to the Plane-Based Geometric Algebra PGA so the signs are different from the PGA4CS.pdf file you can download from https://bivector.net/doc.html , but I think I at least fixed your code for that one example you asked about:
// Import stylesheets
import Algebra, { AlgebraElement } from 'ts-geometric-algebra';
import './style.css';
const PGA2D = Algebra(2, 0, 1);
// > var point = (x,y)=>!(1e0 + x*1e1 + y*1e2)
const point = (x: number, y: number) => PGA2D.fromVector([1, x, y]).dual();
// > var line = (a,b,c)=>a*1e1 + b*1e2 + c*1e0;
const line = (a: number, b: number, c: number) => PGA2D.fromVector([c, a, b]);
// > var dist = (x,y)=>(x & y).Length;
const dist = (x: AlgebraElement, y: AlgebraElement) => x.vee(y).norm();
const a = point(-1, -0.5);
const b = point(-1, 1);
const c = point(1, 1);
// const ab = b.vee(a).normalize();
// const bc = c.vee(b).normalize();
const ca = c.vee(a).normalize();
const a_to_b = dist(a, b);
const b_to_ca = dist(b, ca);
console.log('distance from a to b =', a_to_b);
console.log('distance from b to ca =', b_to_ca);
Hi, I'm from this issue https://github.com/enkimute/ganja.js/issues/150 Trying to understand this library and geometric algebra in general I'm trying to make an example that I can understand and I'm trying to rewrite this simple https://enkimute.github.io/ganja.js/examples/coffeeshop.html#pga2d_distances_and_angles example with this ts-geometric-algebra library https://stackblitz.com/edit/typescript-pj7657?file=index.ts
And I still don't understand how to use it and what methods and functions to use where. For example, in this stackblitz example, I cannot even calculate the distance between two points. I don't even know how to create a point in this library