For those of you who don't remember this from school, trigonometry is the branch of mathematics that deals with the relationships between the sides and angles of triangles. In this chapter we're going to cover the basics of trigonometry, which should handle almost every need you'll have. However, if you would like to learn more about this subject, see Appendix E for book suggestions.

## Why Learn Trigonometry?

When programming a game, you'll often need to do things like find the
distance between two points or make an object move. (In fact, *very
*often!) Here are a few examples:

Rotating a spaceship or other vehicle

Properly handling the trajectory of projectiles shot from a rotated weapon

Calculating a new trajectory after a collision between two objects such as billiard balls or heads

Determining if a collision between two objects is happening

Finding the angle of trajectory (given the speed of an object in the

*x*direction and*y*direction)

You are going to use trigonometry within ActionScripts to complete these (and many other similar) tasks. While you may not need to do so in every single game, the requirement for trigonometry can pop up in any genre. In this chapter I'll discuss the major uses of trigonometry in Flash and how to apply them.