|
![](/i/fill.gif) |
If you have two points P1 and P2, then
the direction D of P2 from P1 is (P2-P1) normalized.
So the gravity F between P1 and P2 is
g*mass1*mass2/(distance P1 to P2)^2,
which is a real number, so you multiply
that by the direction to get a change in the
velocity of P1. (V1=V1+F*D, P1=P1+V1*Time)
For more objects you just calculate each force and
add them onto the velocity. The real problem is this
is O(n^2) to calculate, a thousand objects would
take about a million force calculations to animate
per frame.
Post a reply to this message
|
![](/i/fill.gif) |