To get started with 2D PGA (signature 2,0,1), include the ganja.js script and use the following boilerplate. This setup defines points, lines, and geometric operations like join (vee) and meet (wedge), and includes a built-in graph function to render elements in an SVG.
// Create a Clifford Algebra with 2 positive and one zero generator.
Algebra(2,0,1,()=>{
// Output algebra info to the console.
this.describe();
// In dual projectivized space, the origin is represented by the e12 bivector.
var origin = 1e12, EX=-1e02, EY=1e01;
// Points and lines can be specified directly.
var point = (x,y)=>origin+x*EX+y*EY;
var line = (a,b,c)=>a*1e1+b*1e2+c*1e0;
// Or through join and meet operations.
var join = (p1,p2)=>p1&p2;
var meet = (l1,l2)=>l1^l2;
// Distances and angles
var dist_points = (P1,P2)=>(P1.Normalized&P2.Normalized).Length;
var dist_point_line = (P,l)=>((P.Normalized)^(l.Normalized)).e012;
var angle_lines = (l1,l2)=>(l1.Normalized<<l2.Normalized).s;
// Points and lines can be projected and rejected.
var project = (P,l)=>P<<l*l;
var parallel = (P,l)=>P<<l*P;
var ortho = (P,l)=>P<<l;
// translations and rotations.
var rotor = (a,P)=>Math.cos(a*0.5)+Math.sin(a*0.5)*P;
var translator = (x,y)=>1+0.5*(x*1e02-y*1e01);
// To demonstrate graphing, we create some points and lines.
var A = point(-1,-1), B = point(1,-1), C = point(-1,1), l = line(-1,1,0.5);
// Ganja.js can directly graph 2D PGA elements.
document.body.appendChild(this.graph([
0x444444,
"title",
A, B, C, "Label for point",
l,"Label for line",
()=>[A,B], "Label for segment",
0xffeeee,
()=>[A,B,C], 0xff7777,
()=>[A,B,C], 0xff7777
],{grid:true, animate:false}));
});