[ODE] vector force

David Taylor dajt at tpg.com.au
Sat Feb 3 02:23:26 MST 2007

Thanks for the advice Daniel!

David Taylor.

Daniel K. O. wrote:
> David Taylor escreveu:
>> So to manually add the force of gravity to a spaceship in a space sim, I would make a vector from each spaceship to each gravity source (star, planets), normalise it, and then set the length of the vector to whatever the force of gravity would be at the distance from the body to the spaceship?
> Correct. Now you only have to consider how strong the gravity force
> should be; Newton's law of universal gravitation says it should be:
> F = G * m1 * m2 / d^2
> where:
> - G is the "tweak factor" to make the numbers come out right; on our
> real word it's recommended to be around 6.6742 x 10^-11, but in your
> simulation world it can be anything.
> - m1 and m2 are the bodies' masses.
> - d^2 is the distance squared; if you consider D to be the difference
> vector from the two bodies, D.D (that is, dot product) gives d^2.
> Then just multiply your unit vector by F. More info at
> http://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation
> Try to keep everything close to 1.0 to make ODE happy (remember that G
> is small "to compensate" m1*m2, which is a big number when one of them
> is a planet or a star). You may also want to try something other than
> d^2 as the divisor (e.g. something that grows slower, like d*sqrt(d)).
> --
> Daniel K. O.

More information about the ODE mailing list