For more information, see Trigonometry on Wikipedia. Trigonometry is a branch of mathematics which consists of the study of right-angled triangles — specifically, the ratios of sides of right-angled triangles. Trig (short for trigonometry) functions simply return the ratio of a certain two sides of a triangle, given one angle; or the angle given a ratio of two sides. The point of trigonometry is to be able to quickly relate angles to side lengths and vice-versa to do otherwise complex calculations. For example, finding out the new position of a sprite after it has moved some distance given its direction is impossible without trigonometry.

Basically, trigonometry is a shortcut to find relations between angles and lengths that can be theoretically measured. It is a powerful tool, and has applications in all sorts of fields.

## Angles and Directions

Trigonometry deals with angles and directions. The wider an angle is, the greater the measurement of it is. Below is a depiction of all the angles up to ${\displaystyle 360^{\circ }}$. Angles that are greater than 360 degrees are coterminal to the lesser ones, meaning they lie in the same direction relative to the origin of a coordinate plane and have the same outcome in trigonometric functions.

Notice how the angle increases as it rotates leftward. Rotating the angle to the right decreases it. An angle of ${\displaystyle 180^{\circ }}$, ${\displaystyle 0^{\circ }}$, and any of their coterminal angles depict the geometric figure, a straight line (which are technically quadrantal angles). Scratch directions initiate an analog instead of trigonometric style, therefore being inconsistent with trigonometry. Here are functions to quickly convert between the two:

define Convert trig degree to Scratch degree (trigDegree)
set [scratchDegreeResult v] to ((90) - (trigDegree))

define Convert Scratch degree to trig degree (ScratchDegree)
set [trigDegreeResult v] to ((90) - (ScratchDegree))


## Angle-to-Side Relationship

In trigonometry, an angle is formed between two lines: an initial ray and a terminal ray. The initial ray always lies on the ${\displaystyle x}$ axis. This is because mathematicians prefer it this way - it is a standard that is used to define the trigonometric values. Hundreds of years ago, if mathematicians desired the initial ray to be on the ${\displaystyle y}$ axis, it likely would be today, but the standard was set and trigonometric rules apply to these specific standards. The other line is known as the terminal ray, which can be rotated about the origin of the coordinate plane.

Trigonometry deals with ratios between the initial and terminal lines. An example of this is shown in the following image:

This may seem confusing at first, but the concept is very simple. An angle is formed as the rotation between two lines or segments. The following image depicts angle size increasing:

Notice in the images below, the terminal line comes to a stop and does not go on forever. This relates to a scenario of the distance between two points. For instance, suppose the origin of the coordinate plane is an object. In that case, the end of the terminal side is another object, and the line represents the distance between those two objects, or mathematically "points". The terminal side will always be known as the hypotenuse in terms of geometry and trigonometry.

Where do triangles become involved? Take into consideration the 2D coordinate plane. It has two values of positioning: the ${\displaystyle x}$ and ${\displaystyle y}$ values. A pair of ${\displaystyle x}$ and ${\displaystyle y}$ values used to determine the position of a point is known as an ordered pair. Trigonometry deals with the relationship of ordered pairs. Trigonometry states that:

If any two ordered pairs have three related lines that form a triangle, if that triangle consists of a right angle (90 degrees), the ratio of the sides of the triangle are dependent and consistently based on the angle formed between the initial side and hypotenuse.

## The Functions

There are three major trigonometry functions. To define them, the following name is used:

 Caution: These are relative to angle A. The names change depending on the angle being considered.
• The Sine (${\displaystyle \sin }$) is the Opposite ÷ Hypotenuse
• The Cosine (${\displaystyle \cos }$) is the Adjacent ÷ Hypotenuse
• The Tangent (${\displaystyle \tan }$) is the Opposite ÷ Adjacent

To remember these functions, some people use the mnemonic "SOH CAH TOA".

There functions are expressed as, for example, ${\displaystyle \sin(45^{\circ })}$ or ${\displaystyle \cos(60rad)}$.

There are also three minor trig functions:

• The Secant (${\displaystyle \sec }$) is the reciprocal of the cosine: Hypotenuse ÷ Adjacent
• The Cosecant (${\displaystyle \csc }$) is the reciprocal of the sine: Hypotenuse ÷ Opposite
• The Cotangent (${\displaystyle \cot }$) is the reciprocal of the tangent: Adjacent ÷ Opposite

Reciprocal of any value is simply 1 divided by the value.

Finally, the ${\displaystyle \arcsin }$, ${\displaystyle \arccos }$, ${\displaystyle \arctan }$, ${\displaystyle \operatorname {arcsec} }$, ${\displaystyle \operatorname {arccsc} }$ and ${\displaystyle \operatorname {arccot} }$ are the reverse of their respective trig functions; they convert a trig ratio to the angle. For example, ${\displaystyle \arctan(1)=45^{\circ }}$ implies that ${\displaystyle \tan(45^{\circ })=1}$. However, they are sometimes expressed as ${\displaystyle \sin ^{-1}}$, ${\displaystyle \cos ^{-1}}$, ${\displaystyle \tan ^{-1}}$, ${\displaystyle \sec ^{-1}}$, ${\displaystyle \csc ^{-1}}$, and ${\displaystyle \cot ^{-1}}$. They mean the same thing.

## Using Trigonometric Functions: Example

Trig functions have many uses in programming, especially in graphics and physics simulations. For example, consider a rock thrown at ${\displaystyle 30^{\circ }}$ at ${\displaystyle 5m/s}$. To model the parabolic (curved) path of the rock, split the tilted velocity into a horizontal and vertical velocity, then move the sprite by those values in the respective directions repetitively. Also, it is needed to constantly decrement the vertical velocity to account for gravity.

To split the values, trigonometry is to be used. Image a right triangle with one angle ${\displaystyle 30^{\circ }}$; and hypotenuse ${\displaystyle 5m/s}$. Now, the opposite side must be the vertical velocity and the adjacent side must be the horizontal velocity. To find the opposite side, find the sine of 30°, which is opposite/hypotenuse. Multiply it by the hypotenuse (i.e. ${\displaystyle 5m/s}$). The result, using a calculator to evaluate ${\displaystyle sin(30^{\circ })*5}$ is ${\displaystyle 2.5m/s}$. Similar reasoning can be used to find the horizontal velocity using ${\displaystyle sin(30^{\circ })}$.

 Warning: Note that in some calculators, such as Google Calculator, degrees must be specified, since it assumes radians. However, Scratch always uses degrees, as does Wolfram Alpha.

## Other Uses

• Play around with sin, cos and tangent by drawing its graph using the pen blocks. Since the sin and cos graphs only have a range of ∣y∣≤1, it is helpful to multiply the trigonometric function by a constant (around 100) to see the features of the function.
• Using ${\displaystyle atan}$ to find the direction the mouse is moving in—find the ${\displaystyle atan}$ of the ratio of X motion and Y motion at any given point in time, and you should get the direction in which it is moving.
• Similarly, use ${\displaystyle atan}$ to draw a line with a user defined slope, which passes through another user defined point.
• Using ${\displaystyle atan}$ to make a block called "point towards x:() y:()"—use similar reasoning as the above
• Using a script like the following to make a sprite move in complex paths:
when gf clicked
forever
change [a v] by (1)
go to x: ((100)*([sin v] of (a))) y: ((50)*([cos v] of (a)))


Trigonometric functions are all cyclic, which means they keep repeating. So, complex motions which repeat indefinitely are possible without too much trouble.

• Predicting the position of a sprite after it moves some distance in a specific direction—this is a simple application of sine and cosine. One interesting use of this is to make a sprite move perpendicular to the direction it is facing in, or move in a circle without changing its direction.
• Modeling 3D rotations—this is a much more advanced application of trigonometry. It relies on the principle that any point in 3D, when rotated through some angle, will appear to move straight to a viewer (imagine staring at a single point on a spinning globe). The distance moved can be calculated with some more complex trigonometry.

## Angles Greater than 90°

A sine wave

Angles between 0 and 90 degrees are not the only possible inputs to trig functions. The values of sine, cosine, tangent, secant, cosecant, and cotangent at ${\displaystyle A}$ are the same as the respective values at ${\displaystyle A\,{\bmod {\,}}360^{\circ }}$ (i.e. the remainder obtained when ${\displaystyle A}$ is divided by ${\displaystyle 360^{\circ }}$). This holds for negative values of ${\displaystyle A}$, too. The periodic behavior of the sine function is visualized with the sine wave or sinusoid, where the wave is the same when the graph is shifted horizontally (i.e. the input is changed) by ${\displaystyle 2\pi =360^{\circ }}$. The same applies to the other functions, with different graphs but the same principle.

These equations (identities) about trig functions can be used to calculate their values anywhere given their values between 0° and 90°:

${\displaystyle \sin ={\frac {1}{\csc }}}$ ${\displaystyle \cos ={\frac {1}{\sec }}}$ ${\displaystyle \tan ={\frac {1}{\cot }}}$
${\displaystyle \sin(-x)=-\sin(x)}$ ${\displaystyle \cos(-x)=\cos(x)}$ ${\displaystyle \tan(-x)=-\tan(x)}$
${\displaystyle \sin(x+180^{\circ })=-\sin(x)}$ ${\displaystyle \cos(x+180^{\circ })=-\cos(x)}$ ${\displaystyle \tan(x+180^{\circ })=\tan(x)}$

## For Non-Right Triangles

Trigonometry is not just used with right triangles. The following equations apply to all triangles.

 Note: The lowercase letters a, b, and c are lengths of the sides of a triangle. Capital letters A, B, and C are measures of the angles opposite sides a, b, and c respectively.
An obtuse triangle with its sides as lowercase letters and its angles as capital letters.

### The law of sines

${\displaystyle {\frac {a}{\sin A}}={\frac {b}{\sin B}}={\frac {c}{\sin C}}=2R}$ where ${\displaystyle R}$ is the radius of a circle circumscribed around the triangle.

This identity is extremely useful to relate sides of triangles and angles. Importantly, it also relates the circumradius of the given triangle. The circumradius is the radius of the circle in which the triangle fits perfectly (each vertex lies on the circle).

For this done in Scratch, see Law of Sines.

### The law of cosines

${\displaystyle c^{2}=a^{2}+b^{2}-2ab\cos(C)}$

The obvious use of this surprising but true identity is to find the third side of a triangle given any two sides and the distance between them, or finding the angles given three sides. This has many interesting uses, for example: If you have a spaceship-shooting game like Asteroids, you can program the AI spaceships to aim towards the point where the target will be when the bullet hits it (since during the time taken for the bullet to move, the spacecraft themselves change position linearly).

For this done in Scratch, see Law of Cosines.

### The law of tangents

${\displaystyle {\frac {a-b}{a+b}}={\frac {\tan({\frac {A-B}{2}})}{\tan({\frac {A+B}{2}})}}}$

<(((a) - (b)) / ((a) + (b))) = (([tan v] of (((1) / (2)) * ((A) - (B)))) / ([tan v] of (((1) / (2)) * ((A) + (B))))


### To find the area of a triangle

Area = ${\displaystyle {\frac {1}{2}}ab\sin(C)}$

((0.5) * (((a) * (b)) * ([sin v] of (C))))

Cookies help us deliver our services. By using our services, you agree to our use of cookies.