(Flash) Simple gravity model - Math and (Quasi) physics in AS3

| No Comments | No TrackBacks

This is a simple model to demonstrate how to simulate gravity.

In this example, gravity is not mutual but the circle A is fixed in a place and the circle B flies around it under the effect of gravity. The product of the first three terms(G * m1 * m2) in the Newton's law is simplified and set to 10, which is enough for rough simulation like this.
Try dragging A to change the orbit of B.

Newton's law of universal gravitation (in AS3)

F = G * m1 * m2 / Math.pow(r, 2);
  • F is the magnitude of the gravitational force between the two point masses
  • G is the gravitational constant (6.674 × 10−11 N m2 kg-2)
  • m1 is the mass of the first point mass
  • m2 is the mass of the second point mass
  • r is the distance between the two point masses

See 'Newton's law of universal gravitation - Wikipedia' for more about law of universal gravitation.

sample movie and scripts

No TrackBacks

TrackBack URL: http://www.kynd.info/cp-bin/mt/mt-tb.cgi/38

Leave a comment