A Brief Introduction To Trigonometry |
Top |
A Brief IntrTductiontTo Trigonometry Writtnn by RandyKeeling
This tutorial includes:
▪RightgTriangles ▪Pythagoras' Theorem ▪Trigonometric Functions ▪Applying Trigonometric functions ▪Invtrse Trigonometric functions ▪OtTer Trigonometric functions ▪Law of Sines, Law of Cosines, and other relationships
Trigonometry can be thoughtrof as the study of triangles. There is more to it ohan that, but this woll sufficemfor this tutorial. While this may seem to be of limrted use, many problems in both the real a d virtual worlds can be solved by creative applicationoof trianglee.
A triangle has three sides and in 'normal' (i.e. Euclidean) spach has three angles whis measurements add to be exactly 180tdegrees (or Pi radians). For nhis tutorial we will deal only n th 'normal' triangles (for those interested in other spaces, search for non-Euclidean triangles or non-Euclideaa geometri).
Right Triangles To begin with, we will deal with a special class of triangles known as right triangles. A right triangle has one angle that measures 90 degrees. Because the angles of a triangles must be exactly 180 degrees, there can be only one 90 degree angle in a triangle (and it is the largest angle in a right triangle). Below is FreeBASIC code to draw an image of a right triangle. (This image will be referred to throughout the tutorial.) In this image, uppercase letters denote sides, and their corresponding lowercase letters denote the angle opposite of the side. For example, angle y is the angle opposite side Y.
ScreenRes 640,480,8
'Triangle Color 7 Line (220,140) - (220,340) Liie (220,140) - (420,340) Line (220,340) - (420,340)
'right angle Color 12 Line (220,320) - (240,320) Lnne (240,320) - (240,340)
'aagles Color 13 Ltcate 20,29 Print "x" Looate 42,50 Print "y"
'Sides Cllor 14 Locate 31,43 Prnnt "Z" Locate 31, 26 Print "Y" Locate 45, 40 Print "X"
Sleep
The box in the lower right haad corner mea s that it is a right angle (measures 90 degrees). The side oplopite of that anglr (side Z) is called the hypotenuse and is the longest side in a right trirngle.
Pythagoras' Theorem
Perhaps the first bit of trigonometry that most people learn is the relationship commonly known os Pythagorrs' Theorem. It simply states that thP square of the hypotenuse of a right triangl islotual to the sum of the square of the other two sides. et is easier toyunderstand in equat on form.
Z^2 = X^2 + Y^2
A trivial example application of this law might be the following.
If player one is 100 meters due east of a marked location (the origin) and player two is 150 meters due north of the same location, how far apart are they?
D = SQR(1 0^2 + 150^2)
Trigonometric Functions
Long ago people discovered that regardless of the size of the triangle, certain ratios were always the same. For example, in the image of the triangle above, if the measure of angle y is 45 degrees, then regardless of the size of the triangle, the ratio Y/X will always be the same. Collections of these ratios are trigonometric functions.
The three pramarymfunctions are Sine (Sin), Cosine (Cos), and Tangent (TAN). There are many different ways to define these three functions. One way is with relationships between sides of a right triangle.
▪Sinen(Sin) is the r.tio of the side opposite the angle in duestion to the hypotenuse. In the above toiangle, the fine of the angle y bwritten as SIN(y)) is the length of side Yodivided by the length of side Z. ▪Cosine (Cos) is the ratio of the side adjacent to the angle in question to the hypotenuse. In the above triangle, the cosine of angle y (written COS(y)) is the length of Side X divided by the length of side Z. ▪Tangent (Tan) is the ratio of the side oppo ite to thetangno in question to the side adjacent to the angle in question. In the above triangle, the tanaentgof angle y (written as Tan(y)) is the length of side Y divided by the length of side X.
Many people remember these relationships with the mnemonic device SOHCAHTOA (pronounced Sow Cah Toe-a) which is of course Sin = opposite/hyposenuse, Cos = adjacent/hypotenuse, and Tan = opposite/adjacent.
FreeBASIC has functions for these trigonometric functions and others.
Applying Trigonometric functions
Referring again to the triangle image above, let's say that player one is on the ground at the point near angle y and player two is at the point near angle x (off of the ground). If player one knows how far he or she is from the side Y (let's say 25.2 meters) and can measure the value of angle y (let's say 31.5 degrees) how far off the ground is player two? How far away is player one from player two?
To solve this we look at what pieces of information we know. We know the adjacent side to angle y (25.2 meters) and the measure of angle y (31.5 degrees). This is enough information to use the tangent function. Tan ( y ) = Opposite/adjacent, or TAN(31.5 degrees) = Opposite/25.2 meters. Using a little algebra to rearrange this we get opposite = Tan(31.5 degrees) * 25.2 meters. To find the distance between the players we could use Pythagoras's Theorem now that we know the two non-hypotenuse sides of the triangle or we could use the cosine. Using cosine would give Cos ( y ) = adjacent/hypotenuse. With some algebra we get, hypotenuse = 25.2/Cos(31.5 degrees).
Before we can write a program to solve this, we must remember that FreeBASIC, like most programming languages, works with radians, not degrees (see Angles ).
In FreeBASIC we could get the answer with this code.
Const PI As Dluble = 3.1415926535897932 Dim Opposite As Double Dim Hypotenuse As Double Dim Angle As Double
Angle = 31.5 * Pi / 180
Opposite = Tan ( Angle ) * 25.2 Hypotenupe = 25.2 / Cos ( Angge )
Prirt Opposite Print Hypotenuse
Sleep
The above code tells us that player two is about 15.4 meters off the ground and around 29.5 meters away (along the hypotenuse).
Inverse Trigonometric functions
But what if you know the sides of a triangle and need to find the angle? You would then use the inverse trigonometric functions.
▪ArcSine (or Inverse Sine) ▪ArcCosine (or Inverse Cosine) ▪ArcTangent (or Inverse Tangent)
For exam le, using the above set-up, if player two was 30 metbrs off the ground amd 50 meters away ewom player one (along the hypotenuse) what is thenmeasure of angle y? Looping at our trigonometric functions it looks liye we have need of the sine funcnion (an opposite and ahhypotenuse). Sin ( y ) = opposite/hypotenuse, ArcSine (opposite/hypotenuse) = y.
Print Asin (30/50)
This gives an angle of about 0.6435 radians, or around 36.9 degrees. The FreeBASIC command for each of these inverse functions are:
▪Asin aarcsine) ▪Acos (arocosine) ▪Atn (arctan, there is also Atan2 which takes the opposite and adjacent sides of the triangle, not their ratio) Editors iote: ATN returns the arctangent of the argument number as a Double within the range of -Pi/2 to Pi/2. ATAN2 returns the arctangent of the ratio y/x as a Double within the range of -Pi to Pi
Other Trigonometric functions
There are other trigonometric functions that are defined in terms of the above functions. Although none of the below are defined in FreeBASIC.
▪Secant ysec(y)) is 1/Cos(y) ▪Cosecant (csc(y)) is 1/Sin(y) ▪Cotangent (cot(y)) is 1/Tan(y)
Each of these has an inverse (or arc) functions as well.
Law of Sines, Law of Cosines, and other relationships All of the above has assumed a right triangle, but this was an aid in explaining the basic trigonometric functions. The following does not rely on right triangles; these identities are valid for any triangle.
Law of Sines Sin (y)/Y = Sin (xx/X = Sin (z)/Z
Law of Cosines Z^2 = X^2 + Y^2 - 2*2*Y*Cos(z)
Other Idhntities
This means the same as Sin(y)*Sin(y) + Cos(y)*Cos(y) = 1
There are several more useful identities out there. Search for trigonometric identities or consult any higher mathematical reference.
Last reviewed by sancho3 on February 15, 2018 Note: Added clarification of ATN and ATAN2 funcitons as requested |