does this look right ? (Gravitation)

Started by
2 comments, last by Enselic 17 years, 10 months ago
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/&#106avascript/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 ?
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]
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
Ahh... so i need to use the ReciprocalForce as a measure devided by opposite mass...

hmm
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]
[s]--------------------------------------------------------[/s]chromecode.com - software with source code

This topic is closed to new replies.

Advertisement