# Simple gravity?

This topic is 3531 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

F = GMm/R² for gravity right. That gives you force in Newtons. How do you convert Newtons to a more easily understandable value of acceleration? And is there an easier equation to use? Thank you in advance.

##### Share on other sites
1) F = ma
2) And the probably is an easier formula depending on what information you have and what information you actually want. Care to elaborate on what you are doing?

##### Share on other sites
Asteroids/Newtonian physics style top down 2D game. Stars, planets, black holes, etc. Just trying to find the best way to determine the gravitation pull between said objects and whatever else I choose to add and the best way to move them accordingly.

I think I might have answered my own question but I'm interested to see how other people solved this.

Thank you for the quick response BTW.

##### Share on other sites
Using F=ma you can go:

    F' = GM'M"/R²  M'a' = GM'M"/R²    a' = GM"/R²

And remember that the force (and therefore acceleration) work both ways...

##### Share on other sites
Yeah I was looking at a web site and started to come to that conclusion. I didn't know before that a Newton == kg/m^2

Alright on to the next question: Do I need to work with realistic numbers to make this work or is there an easy way to scale the numbers down to a more practical level?

##### Share on other sites
Think of the final equation in Codeka's post in terms of what it means physically: acceleration of an object is proportional to the mass of the other object and is inversely proportional to the square of the distance between them. The G is a constant and can be discarded - that just changes the scale of the simulation. Your game is likely to already have a 'scale' in the sense that the visible screen covers 'x' units of world-space. So, do some simple order of magnitude estimates for what kind of accelerations you want in your game and the typical distance between objects (measured in the units of your game of course.) Plug those numbers into the equation to determine the typical mass values required and then tweak them for specific game objects until you get a fun and playable balance.

(Caveat: this assumes you're not trying to make a physically accurate simulation of course! IMO the more general advice, at least for games not overly bound by realism, is not to be scared to tweak the laws of physics in order to make your game more fun.)

##### Share on other sites
a' = M"/R²

Does it matter which mass M" is or does M" need to be the major attractor (the planet) of the pair? Also does this assume that M" is vastly more massive then M'?

If I wanted bodies to be mutually attracting do I go back to a' = M"M'/R² ?

Thanks again for all the help.

##### Share on other sites
You've got two object, M' and M" - it doesn't matter which is which. You're trying to calculate the acceleration of both of them due to the other.

So the a' for the first body is related to M" -- the other object. You apply the same equation to both bodies, using the "mass" of the other body to work out the acceleration of the current body.

A massive planet will not be (noticably) affected by a tiny space ship because M" of the ship is insignifcant, but a tiny space ship will be very much affected by a massive planet.

##### Share on other sites
I figured that that was the case. Just though i'd ask to make sure.

Thanks.

##### Share on other sites
As far as what units to use... you should pick a system of units and make it common to everything that you do.

Popular systems include MKS (Meters, Kilograms, Seconds), CGS (Centimeters, Grams, Seconds), and SI (Now the 'standard', similar to MKS)

You can make up your own system.. for example, your unit of length could be the 'mansheight', which is defined as the height of the default player avatar.. or maybe you want to go with the 'hallwidth', which is defined as the width of a standard hallway.

Personally i've always liked CGS because centimeters and grams has much more precision when restricted to integer than you get with meters and kilograms. In the floating point world the choice of system is more or less arbitrary (no advantages regardless)

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 19
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631760
• Total Posts
3002176
×