Sunteți pe pagina 1din 38

Basic Mathematics Refresher

John A. De Goes
June 13, 2005

Contents
1 Introduction

2 The Real Numbers

2.1

The Uses of Numbers

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

The Computer Version of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.2

The World of Real Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.3

Letter Symbolism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.4

The Real Number Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.5

Properties of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.6

The Operations of Real Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.6.1

Order of Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.7

The Properties of Real Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.8

Properties of Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.9

Properties of Exponents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.1.1

3 Algebra Demystified

10

3.1

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3.2

Equations and Their Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3.3

Solving Single-Variable Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


3.3.1

3.4

Worked Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Solving Multi-Variable Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13


3.4.1

A General Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.5

Solving Other Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3.6

Simplifying and Rearranging Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15


3.6.1

Collecting Like Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3.6.2

Factoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.6.3

Expanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1

4 All About Functions

17

4.1

Non-Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.2

Inverse Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.1

4.3

4.4

Computing Inverse Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Common Mathematical Functions

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.3.1

The Square Root Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.3.2

Exponential Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.3.3

Logarithmic Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Using Functions to Solve Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


4.4.1

Worked Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.4.2

Solving Quadratics with the Square Root Functions . . . . . . . . . . . . . . . . . . . . . . . . 22

5 Basic Geometry
5.1

23

Measure of Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.1.1

Graphing Functions and Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

5.2

Equations of Geometric Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

5.3

Intersections of Geometric Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26


5.3.1

Line-Line Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5.3.2

Line-Sphere Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

6 The Wonderful World of Trigonometry

30

6.1

Measure of Angles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

6.2

Triangles
6.2.1

6.3

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Worked Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

The Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35


6.3.1

Worked Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

6.4

Extending the Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

6.5

The Inverse Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

7 Conclusion

38

Introduction

Ill admit it. Im addicted to math, and no where is this more evident than in my frequent attempts at proselytizing.
Im one of those crazy nut cases who tries to convince everyone to choose a career in a mathematically-oriented field.
And when I say everyone, I truly mean it. My thirteen year old niece. My doctor wife. Heck, even the homeless guy
on the street looking for a handout (Would you like a copy of Shilovs book on elementary and complex analysis,
dear sir?).
Unfortunately for me, convincing someone to take an interest in mathematics is rather like convincing my ten-year
old dog to fetch anything other than her doggy bone (which she doesnt really fetch, since after all, she does eat it!).
In other words, it isnt going to happen without the proverbial Act of God.
The problem, I am convinced, isnt that mathematics is the brain-twisting subject most claim it is. Noin terms
of intellectual demand, learning applied math is no more challenging than learning about economics, geography,
or astronomy. The problem is that most people who know math dont know how to teach it in a way that nonmathematicians can understand. So when they try to explain some of the complex concepts in mathematics, they
end up confusing their students, and scaring them away from mathematics for life. (On the bright side, I suppose I
should thank math teachers for doing such a bad job, since otherwise Id be out of a job!)
In this seminar, Im going to show you just how easy and entertaining mathematics can be. Ill cover all the topics your
teachers covered in high school, including real numbers, exponentials, square roots, basic geometry, trigonometry,
and that most dreaded and despised subject of all, algebra. By the time Im done, hopefully Ill have made a new
convert to the wonderful world of mathematics.
Lets start our journey by exploring different kinds of numbers and their place in mathematics.

The Real Numbers

Mathematics, at least at the applied level, is all about numbers. We can use numbers to talk about things in our
world. For example, using numbers, we can describe the distance from the earth to the moon, or the amount of flour
in a recipe for cookies (which I know by heart2.25 cups, to be precise).
There are several different classes of numbers. Each class has a name that you should become familiar with, since
the names are used so often. These classes, their definitions, and the symbols used to represent them are listed in
Table 1.
Name
Integers
Rational numbers

Irrational numbers

Real numbers

Description
{ . . . , -3, -2, -1, 0, 1, 2, 3, . . . }
All numbers that can be written in the
form p/q, where both p and q are integers, and q 6= 0.
All numbers that cannot be written in
the form p/q, where both p and q are
integers, and q 6= 0.
All rational and irrational numbers.

Symbol
Z
Q

Table 1: The common classes of numbers.

Before I talk about the uses and properties of these numbers, I should comment on Table 1.
As you can see, the set of rational numbers contains the set of integers (meaning, every number that is an integer is
also a rational number, since you can write an integer X in the form X/1). The set of real numbers, in turn, contains
the sets of integers, rational numbers, and irrational numbers.

Notice that a rational number is defined as any number that can be written as one integer divided by another.
For example, the number 5/2 is a rational number, since we can write it as the integer 5 divided by the integer 2.
Similarly, the number -9 is a rational number, since we can write it as the integer -9 divided by the integer 1.
What may not be obvious is that repeating decimal numbers are also rational numbers. By decimal number, I mean
the portion of the number that follows the decimal point. For example, the .123 part of 9.123. If the decimal number
repeats forever, as in 3.333 . . ., we can write it as one integer divided by anotherin this case, 10/3. The proof of
this is quite simple but requires algebra (which, technically, you havent re-learned yet!), so for now youll just have
to trust me.
Another fact that may be surprising is that there are some numbers that do not repeat, and which cannot be written
as one integer divided by another. These are the irrational numbers, and they have an infinite decimal expansion
(i.e. the decimal portion does not terminate). The most famous example I can give you of an irrational number is
Pi, usually represented by the symbol , which is approximately equal to 3.14159265359.
The last thing I want to talk about is the set of real numbers. Every number is a real number. At least, every number
youre going to encounter in this seminar is a real number. In truth, there are such things as imaginary numbers,
from whence real numbers get their name, but dont let their names confuse you. Both real and imaginary numbers
dont exist outside human minds. They are both concepts, ideas that humans use to organize their thoughtsand
consequently, have no more a real existence than the idea of Saturday.
Now that youre familiar with the different classes of numbers, its time to look at both the uses these numbers have,
and also some of their properties.

2.1

The Uses of Numbers

Just as different kinds of tools have different uses, so also, the different classes of numbers are used for different things.
Some figures, such as the number of enemy units in a computer game, are ideally described by integers. Other figures,
like the distance from one player to another in a multiplayer game, are better described by real numbers.
But whether by integers or real numbers, virtually everything in a computer game is represented by numbers. The
objects in the game world, the colors painted on the objects, the positions of all the characters, even the brains of the
computer characters. Moreover, not only is all this represented by numbers, but to generate the view of the game
world, you must use hundreds of equations, each involving more numbers. Truly, computer game programming, just
like mathematics, is all about numbers.
2.1.1

The Computer Version of Numbers

Computers cant actually store most real numbers, since most real numbers are irrational, and therefore have infinite
decimal expansions. On todays hardware, you cant store a number with an infinite decimal part unless you have an
infinite amount of space, and no one has that much space. Therefore, computers are restricted to using a small range
of numbers that have a finite number of digits. This excludes all irrational numbers and many rational numbers.
Despite this limitation, the approximation is usually sufficient. Just keep in mind that approximating a real number
with one having a finite number of digits usually introduces error, so an equation which may be true on a sheet of
paper wont be true when you implement it in a program (usually, it will be almost true, but sometimes it wont
even be close). This can lead to a program failing even when it is using the correct equations.
Integers can be represented exactly in computer hardware, but their range is extremely limited. Unlike in mathematics, on a computer, you cant add or multiply two really large numbers, since the result would be too big. The
exact limitations of the integer arithmetic depend on the hardware, but usually, the problem isnt crippling (only a
source of occasional frustration).

2.2

The World of Real Numbers

Learning about mathematics is very much like building a castle out of playing cards. If the foundation isnt secure,
the whole castle will topple long before you reach the top. So just as if we were building a card castle, we need to
make sure our mathematical foundation is secure. Since mathematics (and therefore computer game programming)
is all about numbers, that means making sure were familiar with the conventions, operations, and properties of
numbers. In the sections that follow, well look at each of these topics in depth.

2.3

Letter Symbolism

Sometimes, well need to make broad statements that are true for a whole class of numbers. For example, the
statement 5 + 2 = 7 is true only for specific numbers (since not every two numbers sum to 7). However, other
statements are more broad, like the statement that any number plus zero is equal to that number. Since its
awkward to repeatedly say any number, what we do is denote the number with a letter of the alphabet, such as a
or b. This enables us to simplify a complex sentence like, Any number plus zero is equal to that number, into the
vastly more readable a + 0 = a. When we do this, the context will always make it clear what class of numbers the
letters refer to. Generally, they will be real numbers.

2.4

The Real Number Line

All real numbers are imagined to lie on something called a number line, depicted graphically in Figure 1. The number
line is an imaginary ruler that stretches infinitely to the left, and infinitely to the right. At the center of the ruler
is the number 0. Positive numbers fall to the right of 0, and negative numbers fall to the left, in a continuously
increasing fashion. Every real number has a corresponding location on the number line (its place in the world of
numbers, if you will).

Figure 1: The real number line.


If some number a falls strictly to the left of some number b on the number line, we of course say that a is less than
b, and write a < b. If a falls to the left of a number b, or is possibly equal to b, then we say that a is less than or
equal to b, and write a b. Similarly, if a falls to the right of b on the number line, we say a is greater than b, and
write, a > b. If a falls to the right of b, or is possibly equal to b, we say that a is greater than or equal to b, and
write, a b.
The absolute value of a real number a is defined as the distance from 0 to a along the real number line. If a is
positive, then the absolute value of a is simply a itself. On the other hand, if a is negative, then the absolute value
of a is a.
The absolute value of a is denoted |a|. The formal algebraic definition of absolute value is as follows:

|a| =

a
if a 0
a if a < 0

Figure 2: An interval of the real number line.


The number line can be used to describe intervals. An interval is just a continuous chunk of numbers that lie on
the number line. Intervals are denoted with something called interval notation, in which two numbers are specified,
which correspond to the left and right points of the interval (see Figure 2).
You surround the two numbers on the left with either a left parentheses ( or a left square bracket [, and on the
right with either a right parentheses ) or a right square bracket ]. So, for example, (2, 3), (2, 3], [2, 3), and [2,
3] all denote the interval containing real numbers from 2 to 3. The difference between these intervals is whether or
not the endpoints of the interval are included in the interval. A left parentheses indicates the left endpoint is not
included in the interval, so that, for example, 5 is not included in the interval (5, 10). A left square bracket indicates
the left endpoint is included in the interval, so the interval [-2, 10] includes -2. Similarly for the right side, so that
(-5, 6) does not include 6, while (-5, 6] does include 6.

2.5

Properties of Equations

An equation is a statement claiming equality between two numbers or expressions. For example, the equation 5+2 = 7
claims that 5 + 2 is equal to 7in other words, that both 5 + 2 and 7 are just different ways of denoting the same
number (seven). Another equation weve already seen is a + 0 = a, which asserts that a + 0 and a are different ways
to denote the number a.
The properties of equations are summarized for you in Table 2. Try not to laugh too hard at some of these properties!
They may seem obvious, but they are essential to real number arithmetic (and algebra, as we will see later on).
Note: a, b, and c are real numbers.
Property Name
Property
Reflexive
a=a
Symmetric
If a = b, then b = a.
Transitive
If a = b and b = c, then a = c.
Substitution
If a = b, then wherever a appears
in an expression, it may be replaced with b.
Table 2: Properties of equations.

2.6

The Operations of Real Numbers

The operations defined on real numbers are addition, multiplication, subtraction, and division.
The addition of two real numbers a and b is denoted a + b (big surprise there!). The quantity a + b is called the
sum, while a and b are called the terms. In general, a sum can have any number of terms, even an infinite number
(though such sums are beyond the scope of this seminar).
Notice that you can add terms in any number, and get the same sum. This property is referred to as the commutivity
of addition.
The multiplication of two real numbers a and b is sometimes denoted with the familiar notation a b. More often,
however, you will see it denoted a b, or simply, ab. The reason for this shorthand notation is that multiplication
is perhaps the most common operation, and mathematicians, being the lazy bastards they are, want to simplify
equations as much as possible. So, they decided that to denote the multiplication of two numbers, theyd just write
them side by side, without any symbol at all. If you have problems getting used to this notation, just think of
Einsteins famous equation, E = mc2 , which of course, means that energy equals mass times the speed of light
squared.
In multiplication, quantity ab is called the product, while a and b are called the factors.
Like addition, you can multiply the factors in any order, and obtain the same product. Thus, multiplication is
commutative, just like addition.
Every real number a has another number, denoted a, which is called the additive inverse of a. Thus, the additive
inverse of 10 is -10, while the additive inverse of -2 is 2.1 Subtraction of the real number b from the real number a is
then defined as a plus the additive inverse of b, denoted a + (b), or simply, a b. The quantity a b is called the
difference of a and b. The difference of 5 and 2 is therefore 3.
Subtraction is not commutative; for example, 5 - 2 is not the same as 2 - 5.
Multiplication also has an inverse. Every real number a except zero has another number 1/a, which is called the
multiplicative inverse of a. The product of any real number and its multiplicative inverse is equal to 1. Symbolically,
we can express this as a(1/a) = (1/a)a = 1. The multiplicative inverse of a number is also called the reciprocal of
that number. Thus, 1/5 is the reciprocal of 5, while 10 is the reciprocal of 1/10.
Division of the real number a by the (nonzero) real number b is denoted a b, a/b, or ab . Division of a by b is
equivalent to the product of a and the multiplicative inverse of b. In other words, a/b = a 1/b.
The quantity a/b is called the quotient of a and b, while a is called the numerator and b is called the denominator
(a can also be called the dividend, and b, the divisor, but these names are less common).
The quantity a/b is also known as the ratio of a to b, or the ratio of a and b. Commit this to memory, since I will
use the term ratio frequently.
Division, like subtraction, is not commutative, since, in general, a/b is not the same as b/a.
2.6.1

Order of Operations

When you see an expression involving more than one operation, you need to know how to interpret the expression.
For example, lets take the expression 4 2 5 1. What operations do we apply first? Do we subtract 2 from 4
first? Or multiply 2 times 5? Or subtract 1 from 5? Different answers will yield different results. Mathematics has a
simple rule, which is followed in every mathematical expression you will ever encounter, and also in most computer
programming languages.
The rule is as follows: first, perform all multiplications and divisions, in the order you encounter them, reading the
expression from left to right. Then, perform all additions and subtractionsagain, in the order you encounter them,
1 The additive inverse is so-called because adding any number and its additive inverse leaves you with zero. You can think of a number
as bringing you from zero to the point on the number line corresponding to that number; the additive inverse brings you back to zero.

reading the expression from left to right. So in our example expression 4251, we first look for all multiplications
and divisions. In this case, theres only one, the multiplication of 2 by 5. So we compute the product 2 5 = 10,
and insert this into the expression, leaving us with 4 10 1. Now we perform two subtractions, in a left to right
order, giving us the result of -7.
The rule governing the order of operations doesnt always give us enough control. Sometimes, we want addition to be
performed before multiplication. In this case, we can use parentheses. Parentheses override the order of operations
rule. For example, if we encounter the expression (1 + 2) 3, then we must first add 1 and 2, to get 3, and then
multiply 3 by 3 to get 9. If the parentheses were not there, however, we would first multiply 2 by 3, to get 6, and add
this to 1, to get 7. When parentheses are nested, as in 1 (3 + (4 + 5) 2), you just evaluate them from innermost
to outermost.

2.7

The Properties of Real Numbers

I can now talk about the properties of real numbers. The most common of these properties are listed in Table 3. Most
of these properties are very obviouseveryone knows, for example, that 2 + 3 = 3 + 2 (the commutative property
of addition, which I mentioned in brief in the preceding section). The one property that isnt is the distributive
property.
Property Name
Closure
Commutative
Associative
Identity
Inverse

Distributive

Note: a, b, and c are real numbers.


Addition Property
Multiplication Property
a + b is a real number.
ab is a real number.
a+b=b+a
ab = ba
(a + b) + c = a + (b + c) = (ab)c = a(bc) = abc
a+b+c
a+0=0+a=a
a1=1a=a
For every real number a, For every nonzero real
there exists a unique real number a, there exists
number a, such that a + a unique real number
(a) = (a) + a = 0.
1/a, such that a(1/a) =
(1/a)a = 1.
a(b + c) = ab + ac

Table 3: Common properties of real numbers, summarized.


The distributive property says that multiplication is distributive with respect to addition. That is, if you have three
real numbers a, b, and c, then a(b + c) = ab + ac. In order to see why this is true, we need to go back to the definition
of multiplication. The product a (b + c) just means you add the quantity a to itself a total of (b + c) times. But
surely this is equivalent to adding the quantity a to itself a total of b times, and then adding to this the quantity a
another c times. But adding the quantity a to itself a total of b times is equivalent to computing ab, and adding the
quantity a a total of c times is equivalent to computing ac. So we just add the two sums to get ab + ac, which we
now know to be equal to a(b + c).
The distributive property, though quite simple, is extremely important, and it will be used extensively throughout
this seminar (and most mathematical literature).
Other properties you should be familiar with are shown below:
1. (a) = a
Minus a minus is a plus, as the old saying goes. Minus minus 5 is positive 5: (5) = 5.
2. The product of two negative numbers is positive.
For example, (2)(2) = 4. This convention is more mathematical convenience than anything elseyou cant
really picture negative quantities of things in the real world, let alone multiplication of those negative quantities.
8

2.8

Properties of Fractions

A fraction is simply one integer divided by another nonzero integer. For example, 5/2 is a fraction, since it is equal
to the integer 5 divided by the integer 2. Similarly, 2 is a fraction, since it is equal to the integer 2 divided by the
integer 1.
The properties of fractions are summarized in Table 4.
Note: a, b, c, and d are real numbers, with b 6= 0 and d 6= 0.
Property Name
Property
c
a
Equality
b = d is truth-equivalent to
ad = bc
a
ad
Equivalence
b = bd , d 6= 0
a
c
a+c
Addition
b + b = b
a
c
ac
Subtraction
b b = b
a c
ac
Multiplication
b d = bd
a
c
a d
ad
Division
b d = b c = bc , c 6= 0
a
a
a
Sign Properties
b = b = b
0
Zero Properties
b = 0, b 6= 0
a
0 is undefined.
Table 4: Properties of fractions.
Notice that Ive only described how to add fractions whose denominators are the same. Adding fractions whose
denominators are different is considerably more difficult (and thats why most kids hate justifiably learning about
fractions!). To show how we can do this, lets consider a case from real life.
Suppose we have 1/3 a bucket of water, and 1/5 a bucket of water. If we combine the two, how much water do we
have? We cant use the addition property of fractions, since the denominators arent the same. However, we can use
the equivalence property to make the denominators the same. The equivalence property says that we can multiply
the numerator and denominator of any fraction by any nonzero number, without changing the value of the fraction
(e.g. 1/2 is the same as 2/4, which is the same as 3/6, etc.). So we can multiply both numerator and denominator
of 1/3 by 5, to give us 5/15, and we can multiply both numerator and denominator of 1/5 by 3 to get 3/15. Now
we have two fractions, 5/15 and 3/15, which are equivalent to the original fractions, and yet which have the same
denominator. So we can apply the addition property to give us (5 + 3)/15 = 8/15. So the answer to our original
question is that we have 8/15 a bucket of water (just over a half, since a half would be (7.5)/15).
Generalizing this example is straightforward. Lets say we have two fractions a/b and c/d. Then we just multiply
both top and bottom of a/b by d, to yield ad/(bd), and multiply both top and bottom of c/d by b to get cb/(db).
Now we can add the fractions using the additive property, to get (ad + cb)/(db). Since this seminar is concerned with
mathematics on computers, I wont bother to talk about reducing to lowest terms, a tedious nightmare that involves
trying to divide both top and bottom of the fraction by numbers that both are evenly divisible by (for example, 2/4
can be reduced to 1/2; 8/15, as it happens, cant be reduced any further).

2.9

Properties of Exponents

An exponent is a compact way of writing repeated multiplication. If we want to multiply some number a by itself n
times, then we can write it an . In this representation, n is called the exponent or power of a.
For example, the exponent of 43 is 3. The expansion of this expression is simply 4 4 4.
The expression an is often pronounced a [raised] to the nth power. or a [raised] to the power of n. However,
there are special phrases we use to describe the expression if a is less than four. In particular, a2 is pronounced a
squared, while a3 is pronounced a cubed.
Exponents have their own properties, too, summarized below:
9

1. a0 = 1
2. a1 = a
3. ab ac = ab+c
c
4. ab = abc
5. ab =

1
ab

The kicker is, these properties apply even when the exponents are not integers, but any real numbers at all, whether
whole or fractional, positive or negative. I will admit it is strange to ponder, for example, the quantity 31.5 . What
does it mean to multiply 3 by itself exactly 1.5 times? The answer is that 31.5 is defined to be a number such that
Exponent Property 3 holds, so that when we multiply 31.5 by itself, we get, 31.5 31.5 = 31.5+1.5 = 33 .
In a similar way, Property 5 can be shown to be a logical consequence of the other properties. For example, 21
must have the value 1/21 , so that 21 21 = 21+1 = 20 = 1 (required by Property 3). While the property may seem
unnatural, this strangeness will lessen with time and soon youll find it as familiar as Uncle Bob.
Do familiarize yourself with these properties of exponents, but dont concern yourself with calculating the value of
numbers raised to fractional or negative components. Thats what you have a calculator forput it to good use!
All of the properties we have covered thus far form the basis of algebra, the topic of the next section.

Algebra Demystified

Algebra is one of those subjects dreaded by both children and adultsin the whole realm of mathematics, only
calculus frightens the masses more than algebra. But as you will see in this section, algebra is nothing to be scared
of. Though whole volumes have been written on the subject, the fundamental principles are few and can be stated
simply. With these principles, you will gain an amazing ability to manipulate equationsa highly valued skill in
game development.
Were going to start our tour of algebra with the most fundamental concept: the concept of a variable.

3.1

Variables

A variable is simply a symbol, such as x, which can take on any number of values (possibly any real number at all).
A variable gets its name from the fact that its value is not fixed, but variable.
Variables are usually denoted by single, lower-case letters, such as x, y, z, and w. If an equation or expression
involves more than four variables, then sometimes you will see subscripts, e.g. x1 , x2 , x3 , and so on.
Variables are used to form equations.

3.2

Equations and Their Solutions

An equation is a statement that asserts the equality of two expressions. For example, the equation 2 + 2 = 4 asserts
that the expression 2 + 2 is equal to the expression 4. In this case, the equation is true, because the information it
asserts is factually correct. However, its easy to imagine other statements, such as 1 + 1 = 0, which are false.
Sometimes, if a statement involves variables, the statement can be both true and false, for certain choices of the
variables. Take the statement x + 0 = 3. This statement is true for x = 3, since 3 + 0 = 3, but false for all other
choices of x.
The set of all variable values that make an equation true is said to be the solution of that equation. The variables
are said to satisfy the requirements of the equation, or sometimes, just to satisfy the equation.
10

If you have multiple equations involving variables, then the set of all variable values that satisfy the equation is called
the solution to the equations. Lets take a simple example:
5x 2y = 3
3x + 3y = 0
The solution to this equation is x = 1, y = 1. If you plug these values of x and y into the equations, you will see
they are true, whereas if you try any other values, the equations will be false.
It is often the case in math where you have one or more equations, and want to determine the solution to the
equations. This is such an important topic, we will spend considerable time addressing it in the next section.

3.3

Solving Single-Variable Equations

The first problem we will tackle is solving equations involving a single variable. For example, the equation 4z = 5
is an equation in z, since z is the only variable appearing in the equation.
In order to solve such equations, I must introduce a set of three rules. These rules are not difficult to understand,
nor are they difficult to prove, but they are at the heart of solving equations.
The rules, which I will call The Rules of Solving Equations, can be stated as follows:

Rules of Solving Equations


1. You can add (or subtract) any real number to both sides of an equation without changing the truth of that
equation.
2. You can multiply (or divide) both sides of an equation by any non-zero real number without changing the truth
of that equation.
3. With a few exceptions, you can apply any function to both sides of an equation without changing the truth of
that equation.
I havent introduced the concept of functions, so for now, just ignore Rule 3. Well return to it later. Instead, try to
understand the first two.
So you dont have to take my word for it, I will now present a very brief proof for Rule 1. Lets say we have some
equation, A = B, where A and B may be real numbers, or expressions involving some variables (it doesnt matter).
The equation A = B asserts that A is identically equal to B. In other words, the equation tells you that if you look
on the real number line to find the location of A, and then look to find the location of B, you will see they have the
same locationbecause they are the same number!
There are two possibilities we need to consider: the first possibility is that the equation A = B is true, meaning
that A really is equal to B. The second possibility, of course, is that the equation is lying to us, which means the
equation is false, and A does not equal to B. According to Rule 1, we do not change the truth of the equation 2 by
adding or subtracting any real number to both sides of the equation.
Well cover the proof of each of these cases separately:

Case 1: The Equation is True


If the equation is true, then we have the same number, on both sides of the equation. Lets call this number C
(which is identically equal to both A and B). Then our equation becomes C = C. Certainly, C + k is equal to C + k
(itself!), for any real number k. Therefore, we have established that if the equation is true, adding (or subtracting)
2 That

is, if the equation is false, we wont change it to true, and if its true, we wont change it to false.

11

any real number to both sides of the equation will not change the truth of the equation (that is, wont make the
equation false).

Case 2: The Equation is False


If the equation is false, then A is not equal to B. If this is the case, then there is some gap on the real number line
between A and B. In particular, lets say that A = B + q, where q now is the (signed) gap between A and B.
We know this new equation (A = B + q) is true. Therefore, we can apply the result of Case 1 to this rule. We can
add or subtract any real number to both sides of this new equation, without changing its truth. So lets add k to
both sides of the equation, giving us the new equation A + k = B + q + k. This equation is true for any k.
Since the equation A + k = B + q + k is true for all k, if we subtract some number from one side of the equation,
but not the other, the equation will be false for all k. Therefore, we will subtract q from the right hand side, thus
introducing a gap on the real number line between the left and right hand sides of the equation. Our new equation,
A + k = B + k, will be false for all k.
Therefore, we have established that if the equation is false, adding (or subtracting) any real number to both sides of
the equation will not change the truth of the equation (i.e. it will still be false, no matter what real number we add
to both sides).
3.3.1

Worked Examples

Now we will use our rules to solve a series of simple equations.

5x + 2 = 0
1. Add 2 to both sides of the equation:
5x = 2
2. Divide both sides of the equation by 5:
x=

2
5

Recall that application of our rules doesnt change the truth of the equation. Therefore, if its true that 5x + 2 = 0,
then it must be true that x = 25 . This implies that x = 25 is the sole solution to the equation 5x + 2 = 0. No
other value of x, when plugged into the equation, will produce a true equation.
Keep these ideas in mind when studying the following series of examples.

3z = 6
1. Divide both sides of the equation by 3:
z=

6
= 2
3

9y 6 = 0
1. Add 6 to both sides of the equation:
9y = 6
2. Divide both sides of the equation by 9:
y=

12

6
2
=
9
3

3.4

Solving Multi-Variable Equations

It is often the case that our equations will involve more than just a single variable. The equation x + y = 2, for
example, involves two variables, x and y.
In the equation x + y = 2, we cant solve for both x and y. If we solve for x, we get x = 2 y, and if we solve for
y, we get, y = 2 x. Therefore, the most we can do for such an equation is to solve for one variable in terms of
anotherthat is, solve for x in terms of y, or solve for y in terms of x.
To solve an equation for one variable in terms of a second variable, simply apply our rules to the equation, treating
the second variable as a constant.
A more challenging case occurs when we have both multiple variables, and multiple equations.
Take, for example, the previously introduced set of equations shown below:
5x 2y = 3
3x + 3y = 0
This set of equations involve two variables, and has a single solution (x = 1, y = 1). This system is called a system
of linear equations, because each equation is linear. By linear, I mean the equation is a sum of terms, each of which
consists of a constant real number multiplied by a variable that is raised to the first power (an equation such as
x2 = 2 is not linear). Such systems arise often in computer science.
In the next section, Ill describe a common method of solving systems of linear equations.
3.4.1

A General Approach

A general system of n linear equations in n3 variables looks as shown below:


a11 x1
a21 x1
..
.

a12 x2
a22 x2
..
.

..
.

an1 x1

an2 x2

ann xn

a1n xn
a2n xn
..
.

=
=

b1
b2
..
.

= bn

where x1 -xn are the n variables, the as are the coefficients of those variables (the constants they are multiplied by),
and the bs are additional constants.
For example, the following is a system of three linear equations in three variables:
4x + 3y
2x 9y
(0x) + 2y

z
7z
+ 6z

= 4
= 8
= 0

The procedure for solving such systems is straightforward. You dont have to have much creativity, just a lot of
patience, since the procedure involves lots of tedious steps. The potential for making errors (when trying to solve
equations with a pen and paper) is enormousa better approach is to program the procedure into your computer,
and have it do the ugly work for you.
A rough sketch of this procedure is detailed below:
1. Take the nth equation (the one at the bottom), and solve it for xn , in terms of all the other variables.
3 Notice

the number of equations equals the number of variables. In general, a system does not have exactly one solution unless this
criterion is met.

13

2. Take your solution for xn , and plug it into all the other equations. You will end up with n 1 new equations.
3. Take the (n 1)th new equation, and solve it for xn1 , in terms of all the other variables.
4. Take your solution for xn1 , and plug it into all the other new equations. You will end up with n 2 new
equations.
5. Repeat the process until, at last, you have an equation for x2 , involving only x1 . Plug this into the equation
for x1 , and solve for x1 . Since the equation only involves x1 , the solution will be a real number.
6. Take your solution for x1 , and plug it into your last equation for x2 , thus giving you a real number for x2 .
7. Take your solutions for x1 and x2 , and plug them into your last equation for x3 , to get the real number solution
for x3 .
8. Repeat the process until you solve for xn , the last variable.
As much as I hate to subject you to it, were actually going to apply this procedure to the previously introduced
system of linear equations. Pay close attention.

Worked Example
Recall the system of linear equations presented at the beginning of this section looked as shown below:
z
7z
+ 6z

4x + 3y
2x 9y
(0x) + 2y

= 4
= 8
= 0

Solving the third equation for z, we find the following:


2
1
z= y= y
6
3
This is our last equation for z. We will take this equation, which gives us z in terms of the variables x and y, and
substitute it into the first and second equations, to give us the following new equations:
4x + 3y ( 13 y)
2x 9y 7( 31 y)

=
=

4
8

Simplifying these equations, we find,


4x +
2x

10
3 y
20
3 y

=
=

4
8

Now we will take the second equation, and solve for y in terms of the other variables, to obtain the following result:
y=

8 2x
24 6x
6
3
= + x
20 =
20
5 10
3

This is our last equation for y. We will take this equation, which gives us y in terms of the variable x, and substitute
it into the first equation. The result is shown below:
4x +

10 6
3
( + x) = 4
3
5 10
14

Simplifying, we obtain the following:


5x = 8
This is our last equation for x, which happens to involve only x. Solving this equation for x gives us the real number
solution shown below:
x=

8
5

We now substitute this into our last equation for y, and simplify, as shown below:
6
3 8
18
y= + ( )=
5 10 5
25
Now we take our solution for x and y, and plug them into our last equation for z, to obtain the solution for z:
1 18
6
z = ( ) =
3 25
25
18
Therefore, the solution to the system of linear equations is x = 85 , y = 25
,z=

6
25 .

Nasty, isnt it? However, despite the awkwardness of the approach, you can use it to solve any system of linear
equations, no matter how large and complicated it may be.
Not all equations can be written in the general form described in this section. For these deviant equations, there are
alternate methods of solving them.

3.5

Solving Other Equations

All the following equations cannot be solved with our method of solving systems of linear equations:
x2 = 3xy + 4x 3y = 0xx = 27
We cant solve these equations, of course, because they are not linear. Non-linear equations can only be solved (if
they can be solved at all) using Rule 3. Ill introduce you to functions, and show how to use them to solve non-linear
equations. But first, well add to our repertoire of mathematical tools by covering how to simplify and rearrange
equationsa critical skill to have when trying to solve more complicated, non-linear equations.

3.6

Simplifying and Rearranging Equations

There are times when youll want to simplify an equation, or write it in a different way that enables you to use some
rule or formula. In many cases, the Rules for Solving Equations will do the job, enabling you to simplify and rewrite
simple algebraic expressions at will. But for more complex equations, youll need a new bag of tricks. The three
right at the top of that bag are collecting like terms, factoring, and expanding.
3.6.1

Collecting Like Terms

Collecting like terms is the simplest of all three operations. To collect like terms, you just try to symbolically add
whatever you can. The result often simplifies complex equations.
For example, just like we can rewrite 3 + 3 as (2)(3) (two times three), we can also rewrite x + x as 2x. Similarly,
we can write 2x + x as 3x, and 5xy 3xy as 2xy.
In essence, collecting like terms takes advantage of the fact that multiplication is repeated addition. So when we see
repeated addition, we can often turn it into multiplication.
15

3.6.2

Factoring

Factoring is another operation that can simplify complex equations. The idea of factoring is to write some expression
as the product of one or more factors, which are themselves sums. This reduces repetition, and condenses the equation.
Take the equation x + yx = 3. The variable x appears in both terms on the left-hand side of the equation. Were
adding one x plus y xs, for a total of one plus y xs. Therefore, we can collect like terms with this expression,
and write it as the product (1 + y)x. This is called factoring (or factoring out) x in the equation. (Note that if you
apply the distributive property to the equation, it will un-factor it, and youll end up with what you started with.)
As another example, take the expression 5x + xz 2 . This is simply the sum of five xs plus z 2 xs, for a total of
5 + z 2 xs. So we can write the expression as (5 + z 2 )x.
To factor effectively, that tangled blob of fat called your brain has to learn to apply the distributive property in
reversei.e. it has to be creative in imagining ways to write an expression as the product of sums. That, or you
could let your grey matter rest and buy either a high-end calculator like the TI-92 Pro, or a ritzy software package
like Mathematica. Why kill more brain cells than you have to?
3.6.3

Expanding

Lets say you have an equation such as x(y + z) = 0. To expand this equation, we can simply use the distributive
property, which implies the left-hand side of that equation can be written xy + xz.
Why would we ever want to expand an equation? Well, take the following convoluted expression:
x(a + y + c) + y(x + a + b) + z(x + y)
There are factors of x and y appearing in all three terms in this sum, but this repetition is not expressed conveniently.
However, if we expand the equation, we get the following,
xa + xy + xc + yx + ya + yb + zx + zy
Now we can collect the like terms:
xa + 2xy + xc + zx + ya + yb + zy
Finally, we can factor first for x, and then for y:
x(a + 2y + c + z) + y(a + b + z)
This is a much simpler and easier to work with equation than the originalbut to get it, we had to apply all three
tricks.
A common expression youll want to expand will have the form (a + b)(c + d). In order to expand this, we just
introduce a new variable, say, X = (a + b). Then our expression becomes X(c + d), which we can expand with the
distributive property to obtain Xc + Xd. Now substituting X = (a + b), we obtain (a = b)c + (a + b)d. Applying
the distributive property twice, we obtain the final result shown below:
ac + bc + ad + bd
These kinds of expressions are so common theres a mnemonic device to help you remember how to do it. Its called
FOIL, and it stands for First, Outside, Inside, and Last. To apply FOIL to the expression (a + b)(c + d), we take the
16

First terms of each sum, which are a and c, and multiply them together (ac). We then take the Outside terms of
each sum, which are a and d, and multiply them together (ad). Next, we take the Inside terms of each sum, which
are b and c, and multiply them together (bc). Finally, we take the Last terms of each sum, which are b and d, and
multiply them together (bd). The expansion is simply the sum of all the products, or,
ac + ad + bc + bd
Note this is equivalent to the earlier derivation.
In case youre visual learner, check out Figure 3 to see a graphical illustration of the FOIL method.

Figure 3: A graphical illustration of the FOIL method.


More complex expressions, such as (x + y + z)(x + y)(a + c(x + y)), can be expanded with repeated application of
the distributive property. You can do a lot of substitutions, but as you get better, you will be able to expand such
expressions in your head, for kicks!
In the next section, Ill introduce functions, which (at least in this seminar) are constructs built from equations.

All About Functions

Before I can introduce functions, I first need to say a few words about sets.
A set is just an unordered collection of items. In math, sets contain numbers. For example, the set of real numbers,
introduced previously, contains all real numbers. Often sets will contain only a range of real numbers.
With that definition in mind, I will now define a function as a rule (or set of rules) that associates every element of
a set A (called the domain) with exactly one element of a set B (called the range). Typically, both of these sets will
contain a range (possibly infinite) of real numbers.
17

Functions are usually denoted by single, lower-case letters of the alphabet, including f , g, and h.
If x is some element in the domain, then f (x) is defined to be the item in the range that the function f associates
with x. This notation is known as functional notation.
All this formalism probably leaves you wondering, Huh? Not to worry. Well go through a number of example
functions that should clear up the concept swiftly and painlessly.

f (x) = x2
1. Rule. The rule of this function associates the real number x2 with the real number x. For example, 5 is
associated with 25, 3 is associated with 9, and (-2) is associated with 4.
2. Notation. Using functional notation, we can write f (5) = 25, f (3) = 9, and f (2) = 4.
3. Domain. The domain of this function is the set of all real numbers. Meaning, no matter what number you
pick, the function associates some other number with it.
4. Range. The range of this function is the set of all real numbers greater than or equal to zero. Why? Because
x2 is never negative (see the Properties of Real Numbers).

f (x) = 0
1. Rule. The rule of this function associates the real number 0 with every real number.
2. Notation. Using functional notation, we can write f (6) = 0, f (0) = 0, and f (4) = 0.
3. Domain. The domain of this function is the set of all real numbers.
4. Range. The range of this function is the real number 0.

f x = xx
1. Rule. The rule of this function associates the real number xx with the real number x. For example, 3 is
associated with 27, -1 is associated with -1, and -2 is associated with 4.
2. Notation. Using functional notation, we can write f (3) = 27, f (1) = 1, and f (2) = 4.
3. Domain. The domain of this function is the set of all real numbers.
4. Range. The domain of this function is the set of complex numbers. (Now forget I just said that, because there
is no way Im covering complex numbers in this seminar!)

4.1

Non-Functions

Ive described what a function is, but it turns out there are lots of mappings or rule sets that might appear to be
functions, but arent. A critical requirement of a function is that it associate each element in the domain with only
one element in the range. Therefore, any rule that associates an element in the domain with two or more elements in
the range is not a function. This kinds of rules do arise in math, computer science, and yeseven game programming.
But you can often decompose the rules into other rules, each of which constitutes a function. Well see an example
of this functional decomposition in a later section.

18

4.2

Inverse Functions

Inverse functions play a very important role in mathematics, particularly in the problem of solving equations.
An inverse of a function f is denoted f 1 , and its defined such that f 1 (f (x)) = x. In other words, an inverse
function undoes the operation of the function. If f (3) = 1 for some function f , then f 1 (1) = 3.
Not all functions have inverses. If a function f associates two different items in the domain with a single item in the
range, then it doesnt have an inverse (since its inverse would have to associate that single item in the range with
the two items in the domainwhich contradicts the definition of a function).
For example, take the function f (x) = x2 . This function has no inverse. To see this, we can choose any x, say x = 2.
Both f (2) and f (2) are equal to 4 (since the square of a negative number is positive). Therefore, f 1 , if it existed,
would have to associate 4 with both 2 and -2. But such a rule doesnt constitute a function, so f has no inverse.
Lets look at a couple example functions and their inverse.

f (x) = 2x
1. Inverse. f 1 (x) = 21 x
2. Proof.
f 1 (f (x)) =

1
1
f (x) = 2x = x
2
2

f (3) = 6
f (1) = 2
f (0) = 0

f 1 (6) = 3
f 1 (2) = 1
f 1 (0) = 0

3. Examples.

f (x) = 3x + 5
1. Inverse. f 1 (x) =

5x
3

2. Proof.
f 1 (f (x)) =

5 f (x)
5 (3x + 5)
3x
=
=
=x
3
3
3

3. Examples.
f (1) = 2
f (5/3) = 0
f (4) = 17
4.2.1

f 1 (2) = 1
f 1 (0) = 5/3
f 1 (17) = 4

Computing Inverse Functions

You may be wondering how I computed the inverse of the functions I provided in the preceding section. Fortunately,
for simple algebraic functions, computing an inverse is easy.
To compute the inverse of a function f (x), just solve for x, treating f (x) as a variable. Lets look at an example.
Say our function is defined as f (x) = x/2 + 1. Then well solve this equation for x, step-by-step.
First, we add -1 to both sides of the equation, to obtain:
19

f (x) 1 = x/2
Next, we multiply both sides of the equation by 2:
x = 2(f (x) 1)
This equation tells us how to get x given f (x). It is therefore the inverse of f . But instead of writing it in the awkward
form f 1 (f (x)), we go with the traditional notation and write it f 1 (x) (performing the substitution f (x) = x),
giving us the following result:
f 1 (x) = 2(x 1)
You should verify that this is indeed the inverse of f i.e. that f 1 (f (x)) = x.

4.3

Common Mathematical Functions

Having defined the concept of functions and covered what inverse functions are, Im now ready to introduce you to
some very common mathematical functions. Youll see these functions everywhere, and youll use them both directly
in the games you write, and in the equations you derive on paper (to generate results you will use in your games).
4.3.1

The Square Root Functions

There are two square root functions, both extremely similar to each other.

The positive square root function, denoted + x, or simply x, is defined to be a positive number y such that y 2 = x.
The domain of the square root function is the set of all non-negative real numbers (because there is no real number
such that, when squared, is equal to a negative number).

For example, 4 = 2, since 22 = 4. Similarly, 9 = 3, since 32 = 9. (These square roots are easy to calculate, but
all non-negative numbers have square roots.)

The negative square root function, denoted x, is defined to be a negative number y such that y 2 = x. The domain
of the negative square root function is the same as the domain as the positive square root function. Note that the
positive and negative square root functions are related as follows:

p
x = ( (x))

Without introducing the concept of separate negative and positive square root functions, you wouldnt be able to
define the square root operation as a function. Why? Since, for example, both 2 and -2, when squared, are equal to
4, so the square root function would have to associate 4 with two numbers, which clearly violates the definition of a
function.
The generalization of the square root functions, which you may have occasion to use, are shown below:

+nx nx

The positive nth root function, denoted + n x, is defined to be a positive number y such that y n = x. Similarly for
the negative nth root function.
You can evaluate the square root function for any real number on a calculator, or with the math library provided by
your programming language (its possible to calculate the square root by hand, but believe me, you dont want to
try!).
20

4.3.2

Exponential Function

The exponential function, often written as exp(x), exp[x], or simply ex , is defined as follows:
exp(x) = ex
where e 2.718281828459045, known as the natural exponent. Why does e have this strange, seemingly random
definition? Good question, one I cant really answer without the assistance of calculus (sign up for my other seminar!).
Suffice it to say its defined that way because the definition is more useful than any other choice of e.
For us primitive mortals, the only practical way of computing the exponential function is to use our calculator (or
equivalent built-in function in a programming language).
4.3.3

Logarithmic Function

The exponential function has an inverse, but for historical reasons, the inverse is not denoted exp1 (x). Rather, it
is denoted ln(x), and pronounced the natural log of x. The natural log is defined so that ln(exp(x)) = x.
The natural log is one of a family of so-called logarithmic functions. Each logarithmic function is uniquely identified
by its base, which, in the case of the natural log, is equal to e.
The logarithmic function with base b, denoted logb (x) is defined to be a number y such that by = x. Hence,
logarithmic functions undo exponentiation. Symbolically, we can denote this property as logb (bx ) = x.

4.4

Using Functions to Solve Equations

Now that we have covered functions, were ready to revisit an old topic: using functions to solve equations. Recall
that we can apply the same function to both sides of an equation, without changing the truth of that equation.
Take the equation x2 = 9. We cannot solve such an equation by adding something to both sides, by multiplying both
sides by some factor, or by any combination of the two. So instead, we will apply the positive square root function
to both sides of the equation, to produce the following result:

x=+ 9=3
Note that we could also have applied the negative square root function to the equation, to give us the solution,
x = 3. Both solutions are perfectly valid, since the original equation is satisfied by both. This particular example
underscores the point that applying a function to both sides of an equation may result in the loss of some solutions
to the equation (unless you knew to apply both negative and square root functions to the preceding equation, you
might think that x = 3 was the only solution).
Just to make sure youre familiar with the idea, well solve a couple of equations with the help of functions.
4.4.1

Worked Examples

2x = 8
To solve this equation, we apply the function log2 to both sides, which results in the following solution:
x = log2 (8)

3x2 2 = 5
21

To solve this equation, we first add 2 to both sides of the equation:


3x2 = 7
Next, we divide both sides by 3:
x2 =

7
3

Finally, we take the square root of both sides:


r
x=

7
3

The symbol (pronounced plus or minus) indicates there are two solutions to the equation, one with a positive
sign (from the positive square root function), and one with a negative sign (from the negative square root function).

x2 + y 2 = 1, x y = 0
Here we have two equations, and two variables. We will first solve the second equation for y, to obtain y = x, and
then we will substitute this into the second equation, resulting in the following new equation:
x2 + x2 = 2x2 = 1
Dividing both sides by 2, we get the following equation:
x2 =

1
2

Taking the square root of both sides, we obtain the two solutions shown below:
r
x=

4.4.2

1
2

Solving Quadratics with the Square Root Functions

An equation in the form ax2 + bx + c = 0 (with x the variable, and a, b, and c real numbers) is called a quadratic
equation. With the help of both factoring, the square root functions, and a little mental effort, its possible to
determine the solution to this equation.
It turns out there at most two real numbers that satisfy a quadratic equation. These numbers can be determined by
using the quadratic formula, listed below:

b2 4ac
2a

b b2 4ac
x2 =
2a

x1 =

b +

22

Basic Geometry

No math refresher is complete without taking a look at geometry. Geometry, of the kind you used in high school,
with its theorems and postulates, is rarely used in game development. Much more common is analytic geometry.
Analytic geometry attempts to marry geometry and algebra, by representing geometry shapes with equations, and
then manipulating the equations to give useful geometric results.
Before I introduce you to a few of these equations, I must first cover a way of measuring pointssince, after all,
points comprise every geometric object.

5.1

Measure of Points

Points can be measured in many different ways. At the most basic level, you can point to a location and say There!
In this case, the location of the point is specified by the direction of your finger, and the first thing that a lightning
bolt coming from your finger would strike (if you could do that kind of thing).
In game development, the most common way to measure points is by using the Cartesian coordinate system.
In the Cartesian coordinate system, points are measured by describing their location on one or more imaginary rulers,
known as axes (singular: axis).
In one dimension, theres just one imaginary ruler, frequently called the x-axis. The x-axis is just like the real number
line: you describe the location of points with a number, which indicates how far to the left (or right) of the origin
(the zero mark on the imaginary ruler) the point resides.
In two dimensions, there are two axes, at right angles to each other. These are usually called the x- and y-axes. In
third dimensions, another ruler, most frequently called the z-axis, is added, which forms a right angle with each of
the other axes.
A full 3D Cartesian coordinate system is illustrated (as best as can be expected in 2D) in Figure 4.
5.1.1

Graphing Functions and Equations

The Cartesian coordinate system can be used to graph a functionthat is, to display a graphical representation of
the function. To graph the function f (x), for example, you simply draw all points of the form (x, f (x)) (or at least,
as many as you can fit in the region you are graphing). This two-dimensional image will give you a feel for how the
function behaves for different values of x.
Figure 5 shows a graph of the function f (x) = x2 . Study this figure well, as it contains the keys to interpreting the
graphs of functions.
To graph a two-dimensional function f (x, y), you draw all points of the form (x, y, f (x, y)). Of course, this is a 3D
point, so you need to use methods of drawing a 3D point on a 2D surface (a topic for another seminar, Im afraid!).
You can also graph equations by plotting the points that satisfy them. For example, the (x, y) points that satisfy
the equation x2 + y 2 = 1 happen to form a perfect circle with radius 1.

5.2

Equations of Geometric Objects

Now that we can measure points mathematicallygive them numbers, to pin down their positionI can introduce
the fundamentals of analytic geometry.
In analytic geometry, basic geometric objects are given equations. These equations are true for all points lying on
the geometric object (in the same sense that the equation 2 + 2 = 4 is true), and false for all other points (in the
same sense that 1 + 1 = 4 is false).

23

Figure 4: The Cartesian coordinate system in three dimensions.

Figure 5: A graph of the function f (x) = x2 .


There are a handful extremely important equations that come up all the time in computer game development. The
first such equation is the slope-intercept equation of a two-dimensional line.

Slope-Intercept
The slope-intercept equation gives you the y coordinate lying on a line given any x coordinate on the line. The form
of the equation is shown below:

24

y = mx + b
The constant m is called the slope of the line, and it is precisely equal to the number of vertical units per horizontal
unit (for a perfectly horizontal line, this would be zero). The slope measures the elevation of the line.
The constant b is called the y-intercept of the line, since it gives you the y value when x = 0in other words, the y
value of the line that intercepts the y-axis.
Figure 6 shows a graphical illustration of the constants of the slope-intercept equation.

Figure 6: A graphical illustration of the slope-intercept equation of a line.

General Form of 2D Line


The second important equation is another equation for a two-dimensional line, only this one can handle lines of any
orientation. This equation, called the general form of the line equation, is shown below:
Ax + By + C = 0
If the line passes through the points (x0 , y0 ) and (x1 , y1 ), then A = y0 y1, B = x1 x0, and C = Ax0 By0 .
I know, youre probably worrying where these come from. The answer requires vector mathematics, so for now just
accept it on faith that the equations really are true.
Equations for a 3D Line
The preceding equations are great for 2D lines, but what about fully three-dimensional lines, of the kind youre likely
to find in a three-dimensional computer game? These lines can be represented with a triple of equations, called the
parametric representation of a line. These three equations give you all points on the line, but require you to specify
a real number in order to generate these points.
For a line passing through the points (x0 , y0 , z0 ) and (x1 , y1 , z1 ), the parametric representation is shown below:
25

x(t) = x0 + t(x1 x0 )y(t) = y0 + t(y1 y0 )z(t) = z0 + t(z1 z0 )


All points lying on the line can be generated by varying the parameter t (hence where the word parametric comes
from). In particular, the points between (x0 , y0 , z0 ) and (x1 , y1 , z1 ) correspond to values of t in the range [0, 1]. For
example, if t = 0, then the equations give us the following:
x(0) = x0 + 0(x1 x0 ) = x0 y(0) = y0 + 0(y1 y0 ) = y0 z(0) = z0 + 0(z1 z0 ) = z0
As you might imagine, the parametric representation can be used for two-dimensional lines, by throwing away the
third equation for z.

General Plane Equation


The next important equation is the general plane equation, which is true for all points (x, y, z) lying on the surface
of a plane. The equation can be written as shown below:
Ax + By + Cz + D = 0
The constants A, B, and C measure the direction the plane faces, while the constant D measures the distance of
the plane from the origin. It is beyond the scope of this seminar to describe the plane equation in depth (it requires
knowledge of vector mathematics). However, I can give you equations for computing the constants given three points
lying on the surface of the plane. These equations are shown below:
A
B
C
D

=
=
=
=

y 1 z 0 y 2 z0 y 0 z1 + y 2 z1 + y 0 z2 y 1 z2
x1 z0 + x2 z0 + x0 z1 x2 z1 x0 z2 + x1 z2
x1 y0 x2 y0 x0 y1 + x2 y1 + x0 y2 x1 y2
Ax0 By0 Cz0

Sphere Equation
The final important equation I will cover here is the equation for a sphere. All points (x, y, z) on a sphere of radius
r must satisfy the following equation:
x2 + y 2 + z 2 = r2
In the next section, well look at one way these important equations are used: to determine the geometric intersection
of geometric shapes.

5.3

Intersections of Geometric Shapes

The geometric intersection (or simply, the intersection) of shape A and shape B is defined to be another shape,
consisting of the set of all points belonging to both A and B. For example, the intersection of two lines is usually
just a point (unless the lines happen to be the same).
Figure 7 shows the intersection of two circles.
Determining the intersection of geometric shapes is of critical importance to many parts of gaming, from physics
(where it can be used to determine if moving objects collide) to graphics (where it can be used to light the scene with
artificial lights). Therefore, well take a look at how the technique is applied to several different kinds of intersections.

26

Figure 7: The intersection of two circles.


5.3.1

Line-Line Intersection

Lets say we have two lines in general form, given by the following two equations:
A1 x + B1 y + C = 0
A2 x + B2 y + C = 0
For each equation, the line is given by all points that satisfy the equation. To obtain the geometric intersection of
the line, we want to determine all points that satisfy both. However, we know that if two lines intersect, then their
intersection will in general be a single point.
Lets call the intersection point (xi , yi ). Then because the intersection point lies on the first line, we know the
following must hold:
A1 xi + B1 yi + C = 0
Similarly, because the intersection point lies on the second line, too, we know the following holds:
A2 xi + B2 yi + C = 0
We have two equations, and two unknowns. Ring a bell? Yes, indeedwe can use our techniques for solving linear
equations on these two equations. The steps are listed below:
1. Solve the first equation for xi .
Add B1 yi C to both sides of the first equation:
A1 xi = B1 yi C
Divide both sides by A1 :
xi =

B1 yi C
A1

27

2. Substitute xi into the second equation and simplify.


The result is shown below:
A2 (

B1 yi C
) + B 2 yi + C = 0
A1

To simplify, we first write the fraction as a sum of fractions:


A2

B 1 yi
C
A2
+ B 2 yi + C = 0
A1
A1

We then rewrite this as shown below:

A2 B1
C
yi + B2 yi + C A2
=0
A1
A1

Lastly, we factor a yi from the equation:




A2 B1
C
+ B2 + C A2
=0
yi
A1
A1
3. Solve the new equation for yi .
Add C + A2 AC1 to both sides of the equation:

yi

A2 B1

+ B2
A1


= C + A2

C
A1



1
Divide both sides by A2 B
A1 + B 2 :

yi =

C + A2 AC1
AA2 B1 1 yi + B2

After performing a little simplification, we get the following:


yi =

A1 C + A2 C
A2 B1 + A1 B2

4. Substitute yi into the expression for xi .


In the first step, we determined the following:
xi =

B1 yi C
A1

Plugging our determined value for yi into this equation, we obtain the following:
B1

xi =

A1 C+A2 C
A2 B1 +A1 B2

A1

After some simplification, we obtain the following:


(B1 B2 )C
A2 B1 + A1 B2
28

Our intersection point is therefore given by the following equation:



(xi , yi ) =

(B1 B2 )C
A1 C + A2 C
,
A2 B1 + A1 B2 A2 B1 + A1 B2

You may wonder what happens if the lines dont intersect, or if they are lying on top of one another. In these cases,
the intersection of the shapes isnt a single point (rather, its nothing, in the case that the lines dont intersect, and
its the line itself if the lines fall on top of each other). In these cases, the denominator will evaluate to zero, resulting
in an (undefined) division by zero. This is maths way of saying youre asking a question that has no answer (shame
on you!).
5.3.2

Line-Sphere Intersection

Computing the intersection between a line and sphere is considerably more difficult, and will require many of the
concepts and mathematical tools reviewed in this seminar.
In order to compute the intersection, well use the parametric representation for a 3D line and the sphere equation.
In general, the intersection of a line and a sphere results in at most two points (but possibly just one, if the line
merely touches the surface of the sphere, or none, if it doesnt intersect it at all). Lets denote the intersection points
(x, y, z), keeping in mind there may be zero, one, or two of them.
Since the intersection points must satisfy the sphere equation, we know the following must hold:
x2 + y 2 + z 2 = r2
Furthermore, since the intersection points must satisfy the line equation, we have the following:
x = x0 + t(x1 x0 )
y = y0 + t(y1 y0 )
z = z0 + t(z1 z0 )
which must hold for some values of t, corresponding to the intersection points.
Now well take the preceding equations for the line, and plug them into the equation for the sphere, to give us the
following:
x2 + y 2 + z 2 =
2
(x0 + t(x1 x0 )) +
2
(y0 + t(y1 y0 )) +
2
(z0 + t(z1 z0 )) = r2
This is an equation solely in t. Theoretically, we can solve the equation for the values of t corresponding to the
intersection points. However, this is a lot easier said than done.
The first thing well do is expand the equation, which can be done in two steps: first, expand the square, and second,
expand the product. Expanding the square, we obtain the following:
(x0 + t(x1 x0 ))(x0 + t(x1 x0 ))+
(y0 + t(y1 y0 ))(y0 + t(y1 y0 ))+
(z0 + t(z1 z0 ))(z0 + t(z1 z0 )) = r2
Now we use the FOIL method of expansion on the products, which leaves us with the following nasty mess:
29

x0 2 + 2x0 t(x1 x0 ) + t2 (x1 x0 )2 +


y0 2 + 2y0 t(y1 y0 ) + t2 (y1 y0 )2 +
z0 2 + 2z0 t(z1 z0 ) + t2 (z1 z0 )2 = r2
Collecting like terms, we get the following result:
t2 ((x1 x0 )2 + (y1 y0 )2 + (z1 z0 )2 )+
t(2x0 (x1 x0 ) + 2y0 (y1 y0 ) + 2z0 (z1 z0 ))+
(x0 2 + y0 2 + z0 2 ) = r2
What does this look like? A quadratic equation, of coursealbeit a quadratic equation from hell. Lets make the
following substitutions to reduce the complexity of the equation:
a = (x1 x0 )2 + (y1 y0 )2 + (z1 z0 )2
b = (2x0 (x1 x0 ) + 2y0 (y1 y0 ) + 2z0 (z1 z0 ))
c = (x0 2 + y0 2 + z0 2 ) r2
4

Our quadratic equation then becomes,


at2 + bt + c = 0
This equation can be solved nicely with the quadratic formula, which produces the following two solutions t1 and t2 :

b2 4ac
2a

b b2 4ac
t2 =
2a
t1 =

b +

A couple of comments are in order. Once you use this equation to get the values of t, then you still have to plug
these values of t into the parametric representation for the line in order to get the intersection points. Also, in the
case there is just one intersection point, then t1 will be equal to t2 . Lastly, if the line doesnt intersect the sphere,
then the argument passed to the square root function will be negative, indicating an invalid condition.
To get this result, we had to use expansion, the FOIL method, factoring, the quadratic equation (which uses the
square root function), and, of course, our analytic geometry (for representing the line and sphere).

The Wonderful World of Trigonometry

Knowledge of trigonometry is widely reputed to be the most valuable asset you can have if stranded in the middle of
the ocean on a lifeboat. No one knows exactly how knowledge of trigonometry could save your life in this situation
(unless perhaps you can bore the sharks to death with your recitals of lengthy trigonometric identities), but everyone
seems to agree that trig, as it is affectionately known, is one of the most practical branches of mathematics. It
enables you to get stuff done in the real world. Which is not too surprising, considering it was invented by the
ancient Greeks to solve real-world problems.
Fundamentally, basic trigonometry is all about trianglestheir angles, ratios, and other properties. In this section,
well cover triangles and their properties in sufficient detail to enable you to use these concepts in game development.
4 Notice

that I added r2 to both sides of our quadratic equation, so I could define c as a sum of all the terms not involving t.

30

6.1

Measure of Angles

It probably comes as no surprise to you that an angle is a measure of the degree of separation between two lines,
or of the degree of rotation of a geometric object. Indeed, we use angles in everyday speech, referring to the 360o
rotation of a joint, or the mounting of some object 90o off the horizontal.
The system for measuring angles that most people are familiar with is degree measure, wherein 360 degrees form a
complete rotation, which is, of course, equivalentfrom a geometric standpointto no rotation at all.
However, a much better system of measure is radian measure, which is used almost exclusively in math, physics,
computer science, and game development. In radian measure, the fundamental unit of measure is the radian,5 and
there are 2 radians in a complete revolution.
In Figure 8, youll see some common angles and what their corresponding measures are under radian measure.

Figure 8: Common angles measured in radians.


The cool thing about radians is that they are related to the distance around a unit circle. In fact, the distance
around a unit circle from one point to another is identically equal to the angle between the points, when measured in
radians (see Figure 9). More generally, = sr, where is the angle between the points, and s is the distance along
a circle of radius r between the points.
Because of their widespread use and relation to the distance around a circle, Ill use radians exclusively in this
seminar.

Angle Terminology Refresher


A right angle is one equal to /2 radians.
An acute angle is one less than a right angle.
An obtuse angle is one greater than a right angle.
5 Actually,

radians are unit-less, but it can help to think of them as having units.

31

Figure 9: The meaning of radians.

6.2

Triangles

Formally, a triangle is the finite section of plane delineated by three non-parallel lines lying on the surface of the
plane. Informally, you already know what a triangle is so you can ignore that formal definition.
What you do need to know, however, is some terminology and a few key facts about triangles.

Triangle Terminology
1. A triangle having one interior angle equal to /2 is called a right triangle.6
2. When one angle of a right triangle is specified, the side adjacent to the specified angle is called the adjacent
side, while the side opposite the specified angle is called the opposite side.
3. The side opposite the right angle in a right triangle is called the hypotenuse.
4. Two triangles having the same interior angles are called similar triangles.

Triangle Facts
1. The sum of the interior angles of any triangle is always equal to radians. No exceptions.
6A

triangle can have at most one angle equal to a right angle.

32

2. Pythagoreans theorem says that for a right triangle, a2 + o2 = h2 , where a is the length of the adjacent side, o
is the length of the opposite side, and h is the length of the hypotenuse.
3. The ratios of the sides
triangle.

of a triangle depend only on the triangles interior angles, and not on the size of the

The triangle terminology, and the first two of these triangle facts are illustrated graphically in Figure 10.

Figure 10: The terminology and properties of triangles.


The Triangle Facts enable us to solve a few kinds of triangle-based problems. In the next section, Ill show you how
by working through a number of examples.
6.2.1

Worked Examples

Two sides of a right triangle have lengths 3 and 4. What is the length of the hypotenuse?
Using Triangle Fact 2, we know the following holds for the right triangle:
32 + 42 = h2
This can be simplified as follows:
25 = h2

Applying the positive square root function to both sides of the equation, we find the solution is h = 25 = 5 (a
negative length wouldnt make sense here, so there is no need to use the negative square root function).

Two interior angles of a triangle are /4 and /8. What is the other interior angle?
7 All

possible ratios are given by x/y, x/z, y/x, y/z, z/x, z/y, where x, y, and z are the lengths of the sides of the triangle.

33

According to Triangle Fact 1, the following must hold for the triangle:
/4 + /8 + =
where is the unknown angle. Solving this equation for , we find,
= /4 /8 = 8/8 2/8 /8 = 5/8

What is the length of side y 0 in the large triangle shown in Figure 11?

Figure 11: Two similar triangles.


The two triangles displayed in 11 are similar triangles, meaning they have the same interior angles. Since the ratios
of a triangles sides depend only on the interior angles (Triangle Fact 3), this means the ratios of the sides of the two
triangles are the same.
According to the Figure, the ratio of x to y is 2. Therefore, we know the ratio of x0 to y 0 is 2. Mathematically, we
can express this fact as follows:
x0
=2
y0
Solving this equation for y 0 , we find that y 0 = x0 /2. Since the Figure tells us that x0 = 8, we know that y 0 = 8/2 = 4.
These and all manner of similar problems can be solved by the Triangle Facts. However, there are a large class of
triangle problems that cannot be solved with just these facts. For example, if I gave you one angle of a right triangle,
and the length of one side, could you tell me the angles and lengths of the other sides? Not without trigonometric
functions.

34

6.3

The Trigonometric Functions

Recall that Triangle Fact 3 says the ratios of a triangles sides depend only on the interior angles of the triangle, not
on the triangles size. This means we could create a massive chart that describes all possible angles, and the ratios
associated with those angles. Moreover, we could encode the information in this chart into a series of functions, one
function for each ratio.
The resulting angle-to-ratio functions would accept two parameters (i.e. they would be in the form f (1 , 2 )),
corresponding to two angles of the triangle (the third one can be deduced from Triangle Fact 1, and therefore does
not need to be specified), and return the ratio of one side to another.
The problem with this approach is that its a bit too general. While the resulting functions would contain lots of
information, they contain more than we need for most cases. Therefore, what mathematicians have done instead is
to fix one angle of the triangle at /2. Therefore, our angle-to-ratio functions need only accept one parameter (i.e.
they are in the form f ()), from whence the other two can be derived. 8
Figure 12 shows a labeled right triangle, whose ratios are determined entirely by the single angle .

Figure 12: A right triangle, with sides labeled adjacent, opposite, and hypotenuse.
Now imagine that you went out and actually measured the ratios, for every possible angle . You could take this
information and put it in a chart. Alternatively, you could encode it as a mathematical function depending on the
angle.
Were going to take the latter approach and define the trigonometric functions shown below:
Cosine
Secant

cos()
sec()

= a/h
= h/a

Sine
Cosecant

sin()
csc()

= o/h
= h/o

Tangent
tan() = o/a
Cotangent cot() = a/o
8 One

is /2, since the triangle is a right triangle, and the other is /2 , according to Triangle Fact 1.

35

For example, the cosine function gives you the ratio of the length of the adjacent side to length of the hypotenuse,
for a given right triangle with angle . Similarly, the sine function gives you the ration of the length of the opposite
side to the length of the hypotenuse, for a given right triangle with angle .
Of course, you dont really have to measure anything or create massive tables to use trigonometric functions: theyre
programmed into your calculator, and available as a built-in part of your programming langauge.
In the next section, Ill walk you through some problems that you can solve using the trig functions.
6.3.1

Worked Examples

The adjacent side of a right triangle is 3 units long, while the angle of the triangle is
/5. What are all the angles of the triangle, and what are the lengths of the other two
sides?
This is a perfect example of a question that cannot be answered with the Triangle Facts. With the trig functions at
our disposal, however, its no problem.
The first thing well tackle is figuring out what the angles of the triangle are, since this part is the easiest. We know
one angle is /5, and since its a right triangle, we know another angle is /2. Therefore, using Triangle Fact 1, we
can deduce the other angle:
/5 /2 = 10/10 2/10 5/10 = 3/10
Hence, the other angle of the triangle is 3/10.
Now were given the length of the adjacent side is 3, while the angle of the triangle is /5.
From the definition of the trig functions, we know that cos(/5) = 3/h, where h is the length of the hypotenuse.
Solving this equation for h, we find that h = 3 sec(/5).
Similarly, we know that tan(/5) = o/3. Solving this equation for o, we find that o = 3 tan(/5).
Note that we could have solved for o first, and then used a and o to compute h, using Triangle Fact 2. The result
would have been the same.
You could get real number answers for the lengths of the sides of the triangle by plugging the results in your calculator,
but since the results are messy, Ive chosen only to give you the symbolic values.

The opposite side of a right triangle is 2 units, while the angle of the triangle is /6.
What is the length of the adjacent side?
From the description, we have the following:
sin(/6) = 2/h
Solving this for h, we find,
h=

2
sin(/6)

According to Pythagoreans theorem, we have,

a =h o =

2
sin(/6)

36

2

22

Therefore, applying the positive square root function to both sides of the equation, we obtain the following result:
s
a=

2
sin(/6)

2
22

Notice we can also solve this problem in a more straightforward way using the tangent function. From the setup of
the problem, we know the following holds:
tan(/6) = 2/a
Solving for the adjacent side, we find,
a=

2
tan(/6)

You should use your calculator to see these two ways of solving the problem are really equivalent.

6.4

Extending the Trigonometric Functions

You may think the domain of the trig functions is [0, ), since, after all, thats the range of an angle of a right
triangle.9 In fact, the domain is the set of all real numbers. What, then, is the meaning of the trig functions outside
the range [0, )?
The trig functions can be defined harmoniously with our prior definitions with reference to a point on the perimeter
of a circle with radius r. This point makes some angle with the positive x-axis. Under this setup, the definitions
of the trig functions become,
cos()
sin()
tan()

= x/r
= y/r
= y/x

As you can see from Figure 13, the definitions are equivalent to the normal definitions for angles in the range [0, ),
and naturally extend the definitions for angles outside that range.

6.5

The Inverse Trigonometric Functions

If you dont believe the title of this sectionthat is, if you dont believe the trigonometric functions can have
inversesthen you are destined to be mathematician. (Actually, as per the introduction to this seminar, even if you
have no problem with the title of this section, I still think youre destined to be a mathematician.)
The trigonometric functions cannot have inverses, because they associated multiple items in the domain with the
same element in the range. For example, the cosine of 0 equals 1. Therefore, if the cosine has an inverse function,
say, cos1 , then cos1 (1) must be equal to 0.
However, the cosine of 2 is also equal to 1. Therefore, cos1 (1) must also be equal to 2. This is a contradiction:
either cos1 (1) equals 0, or it equals 1, it cannot equal both values, by the very definition of a function.
So the trig functions cannot have inverses. Yet, the idea of an inverse is very appealing, as it would allow us to
compute ratios given angles. So what mathematicians have done is to define pseudo inverses, which map from ratios
to angles restricted to a predefined range. These pseudo inverses work perfectly for right triangles (they will always
9 This

follows directly from Triangle Fact 1.

37

Figure 13: The extended definitions of the trigonometric functions.


give you the correct angle for a given right triangle ratio), and provide useful (though often incomplete) information
in other cases.
The trig inverses are denoted cos1 (w), sin1 (w), and tan1 (w), where w here just refers to a ratio (x/r in the case
of the inverse cosine function), and not a coordinate of any sort. Your calculator and compiler should have built-in
functions for evaluating inverses.
If you know the right triangle ratio a/h is 3, you know the angle is simply sin1 (3) (punch that number into your
calculator and see what you get).

Conclusion

Thats it, folksall the math you should have learned in high school, but probably didnt. This math will serve
you well on your journey to become a game developer, since game development, like many other fields of software
engineering, is as intimately tied to mathematics as it is to computer science and game theory.
Rather than viewing this seminar as the last bit of math youll ever have to learn, I encourage you to view it as a first
step on a journey, which doesnt end until you end up with a Ph.D. in mathematics making important contributions
to the theory of Cauchy-Riemann manifolds.
Okay, just kidding (even though it would be nice!). Even so, now you have built the foundation. Built on it. A first
start would be a book on precalculus, or my class on Game Mathematics (heck, youre even ready for my seminar
on calculus). The more math you know, the better your skills as a game developer will be. And given enough time,
even you might find yourself proselytizing the wonders of mathematics. Good luck!
38

S-ar putea să vă placă și