O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

When you have varying accelerations like these it’s only possible to deter
-
mine the acceleration at a specific time. This is achieved by calculating the
gradient of the tangent to the curve at that point.
Force
According to Isaac Newton:
An impressed force is an action exerted upon a body in order to change
its state, either of rest, or of uniform motion in a right line.
Therefore, force is that quality that can alter an object’s speed or line of
motion. Force has nothing to do with motion itself though. For example, a
flying arrow does not need a constant force applied to it to keep it flying
(as was thought by Aristotle). Force is only present where changes in
motion occur, such as when the arrow is stopped by an object or when a
drag racer accelerates along the strip. The unit of force is the Newton,
abbreviated to N, and is defined as:
The force required to make a one-kilogram mass move from rest to a
speed of one meter per second in one second.
There are two different types of force: contact and non-contact forces. Con-
tact forces occur between objects that are touching each other, such as the
frictional force present between the snow and skis of a downhill skier.
Non-contact forces are those that occur between objects not touching each
other, such as the gravitational force of the Earth upon your body or the
magnetic force of the Earth upon a compass needle.
It’s important to note that many forces can act upon a single object
simultaneously. If the sum of those forces equals zero, the object remains
in motion with the same velocity in the same direction. In other words, if
an object is stationary or moving in a straight line with a constant velocity,
the sum of all the forces acting upon it must be zero. If, however, the sum
of the forces is not equal to zero, the object will accelerate in the direction
of the resultant force. This can be confusing, especially in relation to static
objects. For instance, how can there be any forces acting upon an apple sit
-
ting on a table? After all, it’s not moving! The answer is that there are two
forces acting upon the apple: the force of gravity trying to pull the apple
toward the Earth and an equal and opposite force from the table pushing it
away from the Earth. This is why the apple remains motionless. Figure
1.33 shows examples of varying amounts of forces acting upon everyday
objects.
38 | Chapter 1
Physics
We know that if the sum of the forces acting upon an object is non-zero, an
acceleration will be imparted in the direction of the force; but how much
acceleration? The answer is that the amount of acceleration, a, is propor-
tional to the object’s mass, m, and to the total force applied, F. This
relationship is given by the equation:
(1.93)
More commonly though, you will see this equation written as:
(1.94)
Using this equation, if we know how fast an object is accelerating and its
mass, we can calculate the total force acting upon it. For instance, if the
boat in Figure 1.33 has a mass of 2000 kg, and it is accelerating at a rate of
1.5 m/s
2
, the total force acting upon it is:
Also using the equations for force, acceleration, velocity, and position, if
we know how much force is acting on an object, we can determine the
acceleration due to that force and update the object’s position and velocity
accordingly. For example, let’s say you have a spaceship class with attrib
-
utes for its mass, current velocity, and current position. Something like this:
A Math and Physics Primer | 39
Physics
Figure 1.33. From left to right and top to bottom: a falling
apple, an apple resting on a table, a ball rolling down an
inclined table, and a yacht sailing on water
F
a
m
=
Fma=
2000 1.5 3000 N
total
F =

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required