# Trigonometry 101

23pages on
this wiki
 This tutorial is in progressIt may be incomplete. Please help by editing it.

## 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.

 Notation What it means $\left[a, b\right]\,$ This is an inclusive set of numbers. 'Inclusive' means that the numbers 'a' and 'b' are included in the set. $\left(a, b\right)\,$ This is an exclusive set of numbers. 'Exclusive' means that neither numbers 'a' and 'b' are included in the set. $\left[a, b\right)\,$ This is a left-exclusive set of numbers. This means that 'a' is included in the set, but 'b' is not. $\left(a, b\right]\,$ This is a right-exclusive set of numbers. This means that 'b' is included in the set, but 'a' is not. $-\infty, +\infty\,$ This is an infinite number. An infinite number can be either positive or negative. You will generally see these as parts of the above set notations. For example:$\left[0, +\infty\right)\,$ means "any positive value." Also, any set including this as one of its bounds should be written as 'exclusive' on that end.

## 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.

 Name Function Definition Domain (valid input values) Range (valid output values) Robot Battle Function Sine $\sin x = \frac{A}{C}\,$ $\left[-180^\circ, +180^\circ\right]\,$ $\left[-1, +1\right]\,$ sin Cosine $\cos x = \frac{B}{C}\,$ $\left[-180^\circ, +180^\circ\right]\,$ $\left[-1, +1\right]\,$ cos Tangent $\tan x = \frac{A}{B}\,$ $\left[-180^\circ, +180^\circ\right]\,$ $\left(-\infty, +\infty\right)\,$ tan

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° = -90°, 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.

 Name Function Definition Domain (valid input values) Range (valid output values) Robot Battle Function Arcsine $\sin^{-1}\left(\sin x\right) = x$ $\left[-1, +1\right]\,$ $\left[-180^\circ, +180^\circ\right]\,$ asin Arcosine $\cos^{-1}\left(\cos x\right) = x$ $\left[-1, +1\right]\,$ $\left[-180^\circ, +180^\circ\right]\,$ acos Arctangent $\tan^{-1}\left(\tan x\right) = x$ $\left(-\infty, +\infty\right)\,$ $\left[-180^\circ, +180^\circ\right]\,$ atan, atan2*

## 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, atan 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 atan2, 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.