Calculating gravitational force of a single mass

General physics and astronomy discussions not directly related to Celestia
Topic author
dummy
Posts: 10
Joined: 22.09.2003
With us: 21 years 1 month

Calculating gravitational force of a single mass

Post #1by dummy » 22.09.2003, 09:16

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 :D

granthutchison
Developer
Posts: 1863
Joined: 21.11.2002
With us: 21 years 11 months

Post #2by granthutchison » 22.09.2003, 16:47

You're calculating a force but not taking into account the mass it's acting on, I think.
The acceleration of your star under the action of force F will be F/M; the acceleration of your man will be F/m.

Grant

Guest

Post #3by Guest » 22.09.2003, 22:58

I feel like such a newbie :oops: . I totally forget you'd need to share out that force between the mass. I added that and its working perfectly :D. Thanks very much.


Return to “Physics and Astronomy”