Gravity

From DmWiki

In physics, gravity is the force that pulls everything down towards the ground. You can simulate gravity by applying an acceleration to all objects each frame, with a direction toward the ground (commonly the negative Z or negative Y direction) and a magnitude equal to the strength of gravity (a constant) multiplied by the frame time. Note that gravity acts as a constant acceleration rather than a constant force. This is because, mathematically, the gravity force increases proportionally to the mass of the object being pulled.

In outer space, if you want to realistically simulate gravity you can use the inverse square law. If a spaceship is orbiting at a distance r from a planet with mass m, then the spaceship is pulled toward the center of the planet with the acceleration

a = \frac{Gm}{r^2}

where G is the strength of gravity, a constant. (To be absolutely realistic, it is the gravitational constant of the universe, about 6.67 × 10-11 m3 kg-1 s-2.)

See also simple physics.


DevMaster navigation