Wikipedia-logo.svg  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.

Note Note: This article is intended for an audience with some background in math, especially algebra and geometry.

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 . 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 , , 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 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 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:

Trig Triangle.png

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:

Angle Change.png

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 and values. A pair of and 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:


Note Caution: These are relative to angle A. The names change depending on the angle being considered.
  • The Sine () is the Opposite ÷ Hypotenuse
  • The Cosine () is the Adjacent ÷ Hypotenuse
  • The Tangent () is the Opposite ÷ Adjacent

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

There functions are expressed as, for example, or .

Note Note: "rad" stands for Radians, another unit of angles where 2π radians = 360°, and 1 radian = 180/π degrees.

There are also three minor trig functions:

  • The Secant () is the reciprocal of the cosine: Hypotenuse ÷ Adjacent
  • The Cosecant () is the reciprocal of the sine: Hypotenuse ÷ Opposite
  • The Cotangent () is the reciprocal of the tangent: Adjacent ÷ Opposite

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

Finally, the , , , , and are the reverse of their respective trig functions; they convert a trig ratio to the angle. For example, implies that . However, they are sometimes expressed as , , , , , and . 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 at . 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 ; and hypotenuse . 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. ). The result, using a calculator to evaluate is . Similar reasoning can be used to find the horizontal velocity using .

Note 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

Some of these can be attempted to learn more about trigonometry.

  • 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 to find the direction the mouse is moving in—find the 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 to draw a line with a user defined slope, which passes through another user defined point.
  • Using 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
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 are the same as the respective values at (i.e. the remainder obtained when is divided by ). This holds for negative values of , 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 . 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°:

For Non-Right Triangles

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

Note 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

where 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

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

<(((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 =

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

External links

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