Trigonometry 101

Primer on Mathematical Notation Used in this Article
Where possible, this document tries to stick to general mathematical guidelines on notation, so those familiar with it can probably skip this section. However, since most of this isn't taught in the United States Public Education Curriculum until the Calculus level, this is put in here for sake of completeness.

What is Trigonometry?
Trigonometry is the study of the mathematics involved with angles related to triangles. It is used very heavily in algebra, geometry, and calculus.

What Are The Basic Trigonometric Functions (Sine, Cosine, and Tangent)?
The basic trigonometric functions are the basic parts of how we use trigonometry in mathematics in every day use.



It should be noted that in Robot Battle, and most other programming languages, the valid Domains for these functions are made to be, in use, $$\left(-\infty, +\infty\right)\,$$ . It does this, by wrapping the values around to fit in the real domain. It does this by subtracting or adding 360 degrees until it is in range. For instance 270&deg; = -90&deg;, since 270 - 360 = -90.

What Are The Inverse Trigonometric Functions (Arcsine, Arccosine, Arctangent)?
Inverse functions are functions that provide a translation from the result of a function back into a value that was passed in to it. For instance: $$f^{-1}\left(f\left(x\right)\right) = x.$$

In mathematics, inverse functions are usually represented (as above) by inserting a -1 super-script between the function name and its parenthesis. This is because with multiplication, this is the natural way to do it: $$x^{-1} = \frac{1}{x}.$$

But in computer programming it is often difficult to represent a super-script in a quick and efficiently typed manner, so computer scientists usually use the classical naming, 'Arc' Trigonometric functions, which comes from the classical Greek word for 'inverse.'

The inverse functions for trigonometry don't have simple relationships to the actual lengths and angles that the basic functions do, and were only formally defined after the definition of Calculus. Thankfully, most calculators and computers actually implement the underlying calculus into a simple way to do it.

How to use it in Robot Battle
It's all well and good that they work the way they do, but how do you use them?

Atan versus Atan2
Technically, will only return angles in the first and forth quadrants (if you don't know what that means: up and to the right, or down and to the left). This is because it really doesn't have enough information, because it is only passed a single value: $$\frac{Y}{X}$$ . Because of the division, the signs (positive or negative) of both X and Y are lost, and only their total sign is left. For this reason, it is complex and often error prone to convert the result of atan into a real usable value.

For this reason, Robot Battle 1.4 simplified things greatly by adding a function called, which takes two parameters, x and y (Note: In that order). This function does the heavy lifting for you, and returns the proper angle. Unless you really know what you're doing, and have a really good reason, you should always use atan2 instead of atan.

Disclaimer
It should be pointed out that this document in no way is meant as a replacement for a real education. Don't try to use it as an excuse to sleep through your High School trig class.