topical media & game development

talk show tell print

math -- animation 12

math(s) / tutorial(s)

gravitation(s)



  dx = partB.x - partA.x;
  dy = partB.y - partA.y;
  distSQ = dx*dx + dy*dy;
  distance = Math.sqrt(distSQ);
  force = partA.mass * partB.mass / distSQ;
  ax = force * dx / distance;
  ay = force * dy / distance;
  partA.vx += ax / partA.mass;
  partA.vy += ay / partA.mass;
  partB.vx += ax / partB.mass;
  partB.vy += ay / partB.mass;
  


(C) Æliens 23/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.