Jump to content
• Advertisement

# does this look right ? (Gravitation)

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

If you intended to correct an error in the post then please contact us.

## Recommended Posts

i've successfully implemented 2d-Collisions,Gravity and other neat stuff of 'Spheres' and have now begun implementing Gravitational Pull http://www.mdk-photo.com/javascript/Vector maybe i miss-understand gravitation, but should light objects be pulled at heavy objects ? i know that the gravi-field will decrease the power of a heavy object... if you look closely, you'll see that a heavy object will hunt the lighter object... am i doing something wrong ?

#### Share this post

##### Share on other sites
Advertisement
If you want the simulation to be on "ground level" (and it appears so, since the weights of the objects are measured in kilos), then you don't need to incorporate gravitational pull between objects, because it will be very very tiny anyway, so it won't make a difference. You will only need to accelerate all objects in downwards direction.

If you are doing planetary stuff simulations, then the gravitational force due to gravity for two objects will be equal but in opposite directions.

I.e. if object A is pulled towards object B with a force F1, then object B is pulled towards object A by the same force magnitude, but it will be in opposite direction.

If we take an apple and the earth, the apple will pull the earth with a force F2, say 3 N, but since the mass of the earth is gigantic, the earth will not accelerate noticably (since a = F/m). Earth 3 N pull on the apple will however be noticable.

If you are simulating planets, be sure not to use Euler integration (pos += vel * dt; vel += acc * dt;), because then your orbits will be totally messed up after a while.

[Edited by - Enselic on June 11, 2006 11:01:48 AM]

#### Share this post

##### Share on other sites
Ahh... so i need to use the ReciprocalForce as a measure devided by opposite mass...

hmm

#### Share this post

##### Share on other sites
If you are interested in simulating near-planet-surface gravitational behavior, then you don't need to bother about F = ma. To get realistic gravity you only need to do this (every frame):
  for each game object gameObject  {      gameObject.y += gameObject.yVelocity * dt;      gameObject.yVelocity += GRAVITY_CONSTANT * dt;  }
Where GRAVITY_CONSTANT is a constant that depends on the the application units, and dt is a small number representing ellapsed time between two frames.

[Edited by - Enselic on June 11, 2006 12:25:39 PM]

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10
• Advertisement

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002310
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!