ATTENTION READERS! Lucky's VB Gaming Site is no longer active. For updated game programming information and tutorials, please visit The Game Programming Wiki!
Force and Velocity (Frictionless)
"An object in motion remains in motion unless acted upon by an outside force." Thank-you
Sir Isaac Newton! At first this may seem to be contrary to what you'd expect, after all, if
I roll a ball along the floor, it comes to a stop eventually, doesn't it? Well yes, that is
true, but there's an outside force at work: friction. The force of friction between the
ground and the ball (and also the air and the ball) acts to decrease the speed of the ball,
causing it to come to rest at some point.
Now, if we take this discussion out into the vacuum of space (my favourite place!), we will
no longer have this friction to deal with! Alright.. if there are any die-hards out there,
they're probably thinking, "Lucky's stupid! There are still particles and friction in
space!" Ok, well you just shut-up :) I know my astronomy, and I know my physics, but for
our purposes the 3 particles per cubic meter of space (deep space) will cause negligible
friction!
Where was I before those die-hards so rudely interrupted me? Oh yes, frictionless space.
In space, when an object is given a little push it will continue to travel in that direction
infinitely (unless acted upon by ANOTHER force)! Cool, huh? How do we calculate the
resultant speed and direction? A couple of physics equations are all we need:
F = ma
"Force equals mass times acceleration." A force can be anything from gravity (which could
cause our object to orbit!), to thrust from an engine (SPACESHIPS! WOOOO!).
V = Vo + at
"Final velocity equals initial velocity, plus acceleration times time." We will assume, for
now, that the force and initial velocity have the same direction. So, do you notice any
similarities between our two equations? They both contain "a" or "acceleration"... we can
combine the two! Use the force Lucky! :)
V = Vo + (F/m)t
So now, if we know the magnitude and duration of the force, the mass of the object, and
the object's initial velocity, we can calculate the final velocity. Let's say we have a
10000kg spaceship capable of producing 20000N (Newtons) of thrust for 5 seconds, and the
spaceship is already travelling at 5m/s:
V = (5) + (20000/10000) * 5 = 15m/s
Our ship would end up travelling at 15m/s (meters per second). Note that this is essentially
the same as adding two velocities.. the initial velocity, and the velocity induced by the
force. If these two velocities do not have the same direction, we're in a bit of trouble!
Bring on the trigonometry!
Suppose that our ship is travelling with a speed of "So" at an angle of "Theta" (with 0
being straight "up"). Suppose also that our ship (mass = "m") is facing an angle of "Phi"
and is about to thrust with a force of "F" in that direction. The two resultant velocity
"vectors" may not be parallel, we will have to sum their components (X and Y constituent
segments) in order to determine the final velocity of the ship. Let VoSegX and VoSegY
represent the components of the initial velocity, and FSegX and FSegY represent the
components of the velocity due to thrust:
VoSegX = sin(Theta) * So
VoSegY = cos(Theta) * So
FSegX = sin(Phi) * (F/m)
FSegY = cos(Phi) * (F/m)
Hey baby, what's your sine? :) Now, we can add these values together to get the components
of the final velocity vector, and use this to determine the final speed and direction:
Direction = Atn((VoSegX + FSegX)/(VoSegY + FSegY))
Let's hear it for ArcTangent! :) (Atn = Arctangent) Don't forget, however, that arctangent
will only return values in the range from -90 to 90 degrees (-Pi/2 to Pi/2 radians). You
must check the value of (VoSegY + FSegY), if it is less than zero, you must add 180 degrees
(or Pi radians) to the arctangent result to correct.
Keep in mind: all values must be converted to Radians for use in Visual Basic. To convert
degrees to radians, simply multiply by (Pi/180).
Click here to download the source for a little spaceship simulation. It is pure VB, no
DirectX, no nuthin!