Geometric Algebra

Go to this page: https://enkimute.github.io/ganja.js/examples/coffeeshop.html click "New" and then paste this into the window and press "Save", then "Run". It's amazing! See n-Dimensional rigid body dynamics in PGA.

window.d = 3;
Algebra(d,0,1,()=>{
  
  var points = [...Array(2**d)]
      .map((x,i)=>i.toString(2))
      .map(x=>('000'+x).slice(-d))
      .map(x=>x.split('').map(x=>x-0.5))
      .map(x=>!(1e0 + x*[1e1,1e2,1e3,1e4]));
      
  var edges = points.map((a,i)=>points.map((b,j)=>
    (i<=j||(i^j)&((i^j-1))?0:[a,b]
    ))).flat();
  
  var attach = points[2**d-1];
  var F = (M,B)=>{
    var Gravity = !(~M >>> -9.81e02);
    var Damping = -0.25*!B;
    var Hooke = 8*(~M >>> attach) & points[2**d-1];
    return Gravity + Damping + Hooke;
  }
  
  var state = [1, 1e12 + 2e13 + 1e24],
      ds = (M,B)=>[-0.5*M*B,!(F(M,B)-0.5*(!B*B-B*!B))];
      
  return this.graph(()=>{
    for (var i=0; i<10; i++)
       state = state + 1/600 * ds(...state);
    return (1-1e02) >>> [
      ...state[0]>>>edges,
      attach,
      [attach, state[0]>>>points[2**d-1]]
    ]
  },{
    pointRadius : 2,
    lineWidth   : 4,
    animate     : 1
  });
})


Comments

Popular posts from this blog

David Hestenes - Tutorial on Geometric Calculus

David Turner Obituary by Sarah Nicholas Fri 24 Nov 2023

Modeling Probability Distributions and Solving Differential Equations