(Added information on directions and angles.) |
1a3c5e7g9i (talk | contribs) (→The law of tangents: Removing redundant information.) |
||

(35 intermediate revisions by 17 users not shown) | |||

Line 1: | Line 1: | ||

− | '''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. | + | {{April Fools}} |

+ | '''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. It was used by Pythagoras to prove his theory that a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>, if c is the hypotenuse. | ||

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

Line 10: | Line 11: | ||

[[File:Angles.png]] | [[File:Angles.png]] | ||

− | Notice how the angle increases as it rotates leftward. Rotating the angle to the right decreases it. An angle of 180°, 0°, and any of their coterminal angles | + | Notice how the angle increases as it rotates leftward. Rotating the angle to the right decreases it. An angle of 180°, 0°, 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: |

+ | <scratchblocks> | ||

+ | define Convert trig degree to Scratch degree (trigDegree) | ||

+ | set [scratchDegreeResult v] to (((trigDegree) - (90)) * (-1)) | ||

+ | |||

+ | define Convert Scratch degree to trig degree (ScratchDegree) | ||

+ | set [trigDegreeResult v] to (((ScratchDegree) * (-1)) + (90)) | ||

+ | </scratchblocks> | ||

+ | |||

+ | ==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 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 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: | ||

+ | <div style='text-align:center'> | ||

+ | [[File:Trig Triangle.png]] | ||

+ | </div> | ||

+ | 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: | ||

+ | <div style='text-align:center'> | ||

+ | [[File:Angle Change.png]] | ||

+ | </div> | ||

+ | 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 x and y values. A pair of x and 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== | ==The Functions== | ||

Line 18: | Line 43: | ||

[[File:Trig.png]] | [[File:Trig.png]] | ||

− | {{ | + | {{caution}}These are relative to angle A. The names change depending on the angle you consider. |

*The '''Sine''' (sin) is the '''Opposite''' ÷ '''Hypotenuse''' | *The '''Sine''' (sin) is the '''Opposite''' ÷ '''Hypotenuse''' | ||

*The '''Cosine''' (cos) is the '''Adjacent''' ÷ '''Hypotenuse''' | *The '''Cosine''' (cos) is the '''Adjacent''' ÷ '''Hypotenuse''' | ||

Line 36: | Line 61: | ||

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

− | Finally, the arcsin, arccos, arctan, arcsec, arccsc and arccot are the reverse of their respective trig functions; they convert a trig ratio to the angle. For example, arctan(1) = 45° implies that tan(45°) = 1. However, you may also see these as sin<sup> | + | Finally, the arcsin, arccos, arctan, arcsec, arccsc and arccot are the reverse of their respective trig functions; they convert a trig ratio to the angle. For example, arctan(1) = 45° implies that tan(45°) = 1. However, you may also see these as sin<sup>−1</sup>, cos<sup>−1</sup>, tan<sup>−1</sup>, sec<sup>−1</sup>, csc<sup>−1</sup>, and cot<sup>−1</sup>. They mean the same thing. |

==Using Trigonometric Functions: Example== | ==Using Trigonometric Functions: Example== | ||

− | Trig functions have many uses in programming, especially in graphics and physics simulations. For example, consider a rock thrown at 30° at | + | Trig functions have many uses in programming, especially in graphics and physics simulations. For example, consider a rock thrown at 30° at 5 m/s. To model the parabolic (curved) path of the rock, we need to split the tilted velocity into a horizontal and vertical velocity, then move the sprite by those values in the respective directions repetitively. Also, we need to constantly decrement the vertical velocity to account for gravity. |

− | To split the values, we use trigonometry. We image a right triangle with one angle 30° and hypotenuse | + | To split the values, we use trigonometry. We image a right triangle with one angle 30° and hypotenuse 5 m/s. Now, the opposite side must be the vertical velocity and the adjacent side must be the horizontal velocity. To find the opposite side, we find the sine of 30°, which is opposite/hypotenuse. We then multiply it by the hypotenuse (i.e. 5 m/s). The result, using a calculator to evaluate sin(30°)*5 is 2.5 m/s. We can use similar reasoning to find the horizontal velocity using sin(30°). |

{{Warning|Note that in some calculators, such as Google Calculator, you must specify degrees, since it assumes radians. However, Scratch always uses degrees, as does Wolfram Alpha.}} | {{Warning|Note that in some calculators, such as Google Calculator, you must specify degrees, since it assumes radians. However, Scratch always uses degrees, as does Wolfram Alpha.}} | ||

Line 47: | Line 72: | ||

==Other Uses== | ==Other Uses== | ||

You are encouraged to attempt each of these to learn more about trigonometry. | You are encouraged to attempt each of these to learn more about trigonometry. | ||

− | *Using atan to find the direction the mouse is moving | + | *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 atan to make a block called "point towards x:() y:()" | + | *Using atan to find the direction the mouse is moving in{{-}}find the 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 atan to draw a line with a user defined slope, which passes through another user defined point. | ||

+ | *Using 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: | *Using a script like the following to make a sprite move in complex paths: | ||

<scratchblocks> | <scratchblocks> | ||

Line 56: | Line 83: | ||

go to x: ((100)*([sin v] of (a))) y: ((50)*([cos v] of (a))) | go to x: ((100)*([sin v] of (a))) y: ((50)*([cos v] of (a))) | ||

</scratchblocks> | </scratchblocks> | ||

− | + | One of the great things about trigonometric functions is that they are all cyclic, which means they keep repeating. So you can get complex motions which repeat indefinitely without too much trouble. | |

− | *Predicting the position of a sprite after it moves some distance in a specific | + | *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 | + | *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°== | ==Angles Greater than 90°== | ||

− | Angles greater than 90 degrees have trig functions, too. In fact, the sin, cosine, secant, and cosecant of and angle A are the same as the respective function of A% | + | Angles greater than 90 degrees have trig functions, too. In fact, the sin, cosine, secant, and cosecant of and angle A are the same as the respective function of A%360 (i.e. the remainder obtained when A is divided by 360). This holds for negative values of A, too. For tangent and cotangent, the value is A%180. The proofs of these are obvious if one looks at the sine wave or sinusoid, where the wave repeats every 2pi=360° times. The same applies to the other functions, with different graphs but the same principle. |

[[File:SineWave.gif]] | [[File:SineWave.gif]] | ||

Line 71: | Line 98: | ||

===The [[Wikipedia:Law of sines|law of sines]]=== | ===The [[Wikipedia:Law of sines|law of sines]]=== | ||

− | [[File: | + | [[File:Sine Rule.png]] |

This identity is extremely useful to relate sides of triangles and angles. More importantly, though, 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). | This identity is extremely useful to relate sides of triangles and angles. More importantly, though, 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). | ||

Line 77: | Line 104: | ||

===The [[Wikipedia:Law of cosines|law of cosines]]=== | ===The [[Wikipedia:Law of cosines|law of cosines]]=== | ||

− | [[File: | + | [[File:Cosine Rule.png]] |

− | 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 | + | 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). |

===The [[Wikipedia:Law of tangents|law of tangents]]=== | ===The [[Wikipedia:Law of tangents|law of tangents]]=== | ||

<scratchblocks> | <scratchblocks> | ||

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

</scratchblocks> | </scratchblocks> | ||

===To find the area of a triangle=== | ===To find the area of a triangle=== | ||

− | |||

− | |||

<scratchblocks> | <scratchblocks> | ||

− | (((1) / (2)) * (([sin v] of ( | + | (((1) / (2)) * (([sin v] of (A)) * ((B) * (C)))) |

</scratchblocks> | </scratchblocks> | ||

− | For some of these done in Scratch, see [[List of Mathematical Functions Done in Scratch# | + | For some of these done in Scratch, see [[List of Mathematical Functions Done in Scratch#Law of Cosines|Law of Cosines]] and [[List of Mathematical Functions Done in Scratch#Law of Sines|Law of Sines]]. |

[[Category:Computer Science]] | [[Category:Computer Science]] | ||

[[Category:Math Tutorials]] | [[Category:Math Tutorials]] | ||

+ | |||

+ | ==External links== | ||

+ | *[https://scratch.mit.edu/projects/105798078/ A trigonometry tutorial on Scratch] |

## Latest revision as of 01:35, 24 March 2019

**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. It was used by Pythagoras to prove his theory that a^{2} + b^{2} = c^{2}, if c is the hypotenuse.

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

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

## Contents

## 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 360°. 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 180°, 0°, 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 (((trigDegree) - (90)) * (-1)) define Convert Scratch degree to trig degree (ScratchDegree) set [trigDegreeResult v] to (((ScratchDegree) * (-1)) + (90))

## 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 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 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 x and y values. A pair of x and 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 trig functions. To define them, we use the following names for sides:

**Caution**: These are relative to angle A. The names change depending on the angle you consider.

- The
**Sine**(sin) is the**Opposite**÷**Hypotenuse** - The
**Cosine**(cos) is the**Adjacent**÷**Hypotenuse** - The
**Tangent**(tan) is the**Opposite**÷**Adjacent**

To remember these functions, some people use "Soh cah toa", a simple acronym.

We express a trig function as, for example, sin(45°) or cos(60 rad).

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**(sec) is the reciprocal of the cosine. - The
**Cosecant**(csc) is the reciprocal of the sine. - The
**Cotangent**(cot) is the reciprocal of the tangent.

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

Finally, the arcsin, arccos, arctan, arcsec, arccsc and arccot are the reverse of their respective trig functions; they convert a trig ratio to the angle. For example, arctan(1) = 45° implies that tan(45°) = 1. However, you may also see these as sin^{−1}, cos^{−1}, tan^{−1}, sec^{−1}, csc^{−1}, and 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 30° at 5 m/s. To model the parabolic (curved) path of the rock, we need to split the tilted velocity into a horizontal and vertical velocity, then move the sprite by those values in the respective directions repetitively. Also, we need to constantly decrement the vertical velocity to account for gravity.

To split the values, we use trigonometry. We image a right triangle with one angle 30° and hypotenuse 5 m/s. Now, the opposite side must be the vertical velocity and the adjacent side must be the horizontal velocity. To find the opposite side, we find the sine of 30°, which is opposite/hypotenuse. We then multiply it by the hypotenuse (i.e. 5 m/s). The result, using a calculator to evaluate sin(30°)*5 is 2.5 m/s. We can use similar reasoning to find the horizontal velocity using sin(30°).

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

## Other Uses

You are encouraged to attempt each of these 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 atan to find the direction the mouse is moving in—find the 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 atan to draw a line with a user defined slope, which passes through another user defined point.

- Using 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)))

One of the great things about trigonometric functions is that they are all cyclic, which means they keep repeating. So you can get complex motions which repeat indefinitely 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°

Angles greater than 90 degrees have trig functions, too. In fact, the sin, cosine, secant, and cosecant of and angle A are the same as the respective function of A%360 (i.e. the remainder obtained when A is divided by 360). This holds for negative values of A, too. For tangent and cotangent, the value is A%180. The proofs of these are obvious if one looks at the sine wave or sinusoid, where the wave repeats every 2pi=360° times. The same applies to the other functions, with different graphs but the same principle.

## For Non-Right Triangles

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

Note: | Here, a,b,c and lengths of sides, and A,B,C are measures of angles opposite sides a,b, and c respectively. |

### The law of sines

This identity is extremely useful to relate sides of triangles and angles. More importantly, though, 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).

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

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

(((1) / (2)) * (([sin v] of (A)) * ((B) * (C))))

For some of these done in Scratch, see Law of Cosines and Law of Sines.