Chapter 1
A Math and Physics Primer
T
here’s no hiding from it — if you want to learn AI, it helps to know
some mathematics and physics. Sure, you can use many AI techniques
in a “cut and paste” fashion, but that’s not doing yourself any favors; the
moment you have to solve a problem slightly different from the one you’ve
borrowed the code from you’re going to run into difficulties. If you under

stand the theory behind the techniques, however, you will stand a much
better chance of figuring out an alternative solution. Besides, it feels good
to understand the tools you’re working with. What better reason do you
need to learn this stuff but that?
I’m going to write this chapter assuming you know hardly anything at
all about math or physics. So forgive me if you already know most of it,
but I figure this way I’ll catch everyone, no matter what your experience is.
Skim through the chapter until you come to something you don’t know or
you find a topic where you think your memory needs to be refreshed. At
that point, start reading. If you are already comfortable with vector math
and the physics of motion, I suggest you skip this chapter entirely and
come back later if you find something you don’t understand.
Mathematics
We’ll start with mathematics because trying to learn physics without math
is like trying to fly without wings.
Cartesian Coordinates
You are probably already familiar with the Cartesian coordinate system. If
you’ve ever written a program that draws images to the screen then you
will almost certainly have used the Cartesian coordinate system to describe
the positions of the points, lines, and bitmaps that make up the image.
In two dimensions, the coordinate system is defined by two axes posi

tioned at right angles to each other and marked off in unit lengths. The
horizontal axis is called the xaxis and the vertical axis, the yaxis. The
point where the axes cross is called the origin. See Figure 1.1.
1