Sign in to follow this  

does this look right ? (Gravitation)

This topic is 4238 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


Link to post
Share on other sites
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


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

hmm

Share this post


Link to 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


Link to post
Share on other sites
Sign in to follow this