Version 2.0!
Features
Tutorials
Files
Glossary
Projects
Contact
Links
Message Board
Extras
LuckyCam
Old News
Sign Guestbook
View Guestbook
VB Horoscope
VB Photo Album
.
ATTENTION READERS! Lucky's VB Gaming Site is no longer active. For updated game programming information and tutorials, please visit The Game Programming Wiki!

Gravity

Every object (with mass) is attracted to every other object in the universe by the force of gravity. This force is proportional to the mass of the objects, and inversely proportional to the square of the distance between the objects:

F = G(m1)(m2)/r^2

Force equals G (the Gravitational Constant, 6.67259e-11) multiplied by the mass of the two objects, and divided by the square of the distance between them. Now, we also know that:

F = ma

Force equals mass times acceleration. Using these two equations we can, for example, determine the acceleration imposed by one object on another:

F = (m2)a = G(m1)(m2)/r^2
a = G(m1)/r^2

Note: The mass of an object has no effect on the acceleration it feels! It cancels out.

Now, if we apply this equation using the values present on the surface of the Earth (mass = 6.02e24kg, radius = 6400km)...

a = (6.67259e-11)(6.02e24kg)/(6400000m)^2 = 9.81m/s^2

We get 9.81m/s^2, the correct value for acceleration due to gravity on the Earth's surface! For situations directly on the surface of the Earth (or close to it, ie. In the sky), we can assume that this acceleration is always acting straight down - essentially, the Earth is flat. When we're in space, however, the Earth's mass acts as though it were exerting gravity from a point (its center of mass) - it is now possible to fall around the Earth, ORBIT!

Click here to download example source code demonstrating how to cope with both of these situations.