Gravity - planetary style
I have a question: how do I implement gravity on a planetary scale? Implementing it for an object on Earth so that it falls to the ground isn't too hard. But how in hell do I implement it for 2 or more planetary objects so that they are all attracted to each other? What are the formulae for this? Provided that nothing but their masses, sizes, positions and distances are known.
Thanks.
You use newtons formula : the force attracts the 2 planets, and the intensity of the force is given by M1M2/d^{2}. that is, the force is proportional to the product of the planetary masses and the inverse of the square of the distance between them.
go here : gravitation
go here : gravitation
dAB = B - A
aproximation vab = k * norm(dAB)* mB/dAB^2
va = vab + vac + vad...
Are you trying to find this?
Things would become more complicated when you'd have nonspherical gravity field.
van Flandern has interesting pages about gravity here : metaresearch.org
aproximation vab = k * norm(dAB)* mB/dAB^2
va = vab + vac + vad...
Are you trying to find this?
Things would become more complicated when you'd have nonspherical gravity field.
van Flandern has interesting pages about gravity here : metaresearch.org
Quote:aproximation vab = k * norm(dAB)* mB/dAB^2
No, that's wrong. Acceleration != velocity.
Quote:2 or more? Just make sure you aren't trying to solve this: n-body problem
The current equations are impossible to solve ALGEBRAICALLY but numerical solutions can still be 'very' good, good enough for opengl.
Here is my implementation of the nbody problem on our universe (my first opengl program). As you can see, the orbits of every planet even pluto is almost dead on.
http://www.cems.uvm.edu/~sheinric/starfield/
Raghar's equations look a little bit confusing, it goes like this:
Newton's law of gravity: Each particle of matter attracts every other particle with a force which is directly proportional to the product of their masses and inversely proportional to the square of the distance between them.
Stated mathematically, that is:
Fg = Gm1m2/r^2
Where
m1 = mass 1
m2 = mass 2
Fg = force of gravity on m1 in the direction of m2
= force of gravity on m2 in the direction of m1
G = gravitational constant
r = distance between m1 and m2
Newton's second law: F=ma
Let's say we want to find the motion of m1. Then we want to find F(m1) = m1*a(m1)
Rearranging,
a(m1) = F(m1)/m1
a(m1) = (Gm1m2/r^2)/m1 = Gm2/r^2
So the acceleration of m1 is proportional to the mass of m2 divided by the distance squared.
If you have multiple masses, just sum up the accleration caused by each one.
Newton's law of gravity: Each particle of matter attracts every other particle with a force which is directly proportional to the product of their masses and inversely proportional to the square of the distance between them.
Stated mathematically, that is:
Fg = Gm1m2/r^2
Where
m1 = mass 1
m2 = mass 2
Fg = force of gravity on m1 in the direction of m2
= force of gravity on m2 in the direction of m1
G = gravitational constant
r = distance between m1 and m2
Newton's second law: F=ma
Let's say we want to find the motion of m1. Then we want to find F(m1) = m1*a(m1)
Rearranging,
a(m1) = F(m1)/m1
a(m1) = (Gm1m2/r^2)/m1 = Gm2/r^2
So the acceleration of m1 is proportional to the mass of m2 divided by the distance squared.
If you have multiple masses, just sum up the accleration caused by each one.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement