Hey all. I've been working on a small gravity simulation recently for a game demo and I've kinda run into a brick wall. I'm not sure where else to ask and I've been a fan of celestia for a while now so I figured maybe someone from here would know.
I've never taken physics or astrophysics at college/university and my extent of physics have been high school classes. However, I do understand the general idea of things and currently have a small simulation up and running. I'm using the F = G*m*M / r? formula which is giving me some cool results with simple simulations. I've been calculating the force between two bodies and then multiplying it by the normal vector between the two. I know it's probably not the best/realistic way to do it but I'm trying to keep it as simple as possible so that the demo doesn't need a crazy high spec pc to play.
I'm no expert, but I'm guessing my problem is to do with how I calculate the directional force vector between two objects. An example of my problem: I have two bodies, a huge-mass sun and a tiny-mass person. With the method I'm using now, the sun is pulled with equal force towards the man as they are to the sun. When the man's orbit gets close to the sun, the sun itself is pulled out of position and ends up flying off.
Does anyone know a simple but realistic way that I can fix this (either some way of multiplying the result of the gravitational force formula depending on the objects mass, or preferably another formula to retrieve the force of a single mass on a point in space instead of the force between two masses)? I'd be eternally grateful for any help anyone can give
Calculating gravitational force of a single mass
-
- Developer
- Posts: 1863
- Joined: 21.11.2002
- With us: 21 years 11 months