- #1
poo2thegeek
- 4
- 0
For my own personal project I want to simulate our solar system on a computer program.
I understand that the force applied on a body due to gravity can be calculated by dividing the product of the two masses by the square of the distance between them, then multiplying this value by the gravitational constant.
I assume that the direction this force is applied from would be a vector equal to the normalised value of the first body's position subtracted from the the second mass, with the direction being negated for the second mass.
But how would I then calculate the new position of the body.
For my example the sun can be static as the movement it undergoes is too little to bother calculating.
Mercury must have a velocity and a direction down which it is traveling. The suns gravity would attract the planet, but it's inertia would keep in from falling into the sun. I assume I must calculate the the angle tangent to the sun, but how would I go about doing this in 3 dimension?
I understand that the force applied on a body due to gravity can be calculated by dividing the product of the two masses by the square of the distance between them, then multiplying this value by the gravitational constant.
I assume that the direction this force is applied from would be a vector equal to the normalised value of the first body's position subtracted from the the second mass, with the direction being negated for the second mass.
But how would I then calculate the new position of the body.
For my example the sun can be static as the movement it undergoes is too little to bother calculating.
Mercury must have a velocity and a direction down which it is traveling. The suns gravity would attract the planet, but it's inertia would keep in from falling into the sun. I assume I must calculate the the angle tangent to the sun, but how would I go about doing this in 3 dimension?