Trigonometric Functions


Trigonometry is the study of the properties of triangles and trigonometric functions and of their applications. Discussions of trigonometric functions usually refer to right triangles , which have one angle of 90 degrees (see Figure 1 ). There is a set of defined relationships among the trigonometric functions, the lengths of the sides of a right triangle, and the corresponding angles in the triangle. When you know these relationships, you can use the trigonometric functions to solve trigonometric problems.

click to expand
Figure 1: A right triangle has one angle at 90 degrees.

A practical problem that uses trigonometry is to estimate one's distance from a pole or tower of known height. By measuring the observed angle from the ground to the top of the pole, and knowing the height of the pole, your distance from that pole is the height of the pole divided by the tangent of the measured angle. This principle can be applied to golf, sailing, or hiking , to estimate distance from a fixed point of interest (the golf flag, for example, or a radio transmission tower).

The principal trigonometric functions are sine, cosine, and tangent. Each is defined as the ratio between the two sides of a right triangle. The values of these functions for any value of the angle, x, correspond to the ratios of the lengths of the sides of the right triangle containing that angle, x. For a given angle, the trigonometric functions fix the lengths of the sides of the right triangle. Likewise, knowing the lengths of any two sides of the right triangle allows one to compute the value of the angle using one of the inverse trigonometric functions.

OOo Basic uses radians as the unit of measure for angles; however, most non-scientists think in degrees. An angle that is 90 degrees, such as the corner of a square, is Pi/2 radians.

Note  

The built-in constant Pi is approximately 3.1415926535897932385. Pi is a fundamental constant widely used in scientific calculations, and is defined as the ratio of the circumference of a circle to its diameter. The sum of the angles in any triangle-including a right triangle-is 180 degrees, or Pi radians. A tremendous amount of elegant and practical mathematical methods result from this connection between a triangle and a circle. All descriptions of periodic motion build on this foundation, making trigonometry a fundamental and very useful set of mathematical tools.

Using the relationship between degrees and radians, it is easy to convert between radians and degree measurements of angles.

 degrees = (radians * 180) / Pi radians = (degrees * Pi) / 180 

To calculate the sine of a 45-degree angle, you must first convert the angle from degrees to radians. Here's the conversion:

 radians = (45 * Pi) / 180 = Pi / 4 = 3.141592654 / 4 = 0.785398163398 

You can use this value directly in the trigonometric function SIN.

 Print SIN(0.785398163398) ' .707106781188 

To determine the angle whose tangent is 0.577350269189, use the arctangent function. The returned value is in radians, so this value must be converted back to degrees.

 Print ATN(0.577350269189) * 180 / Pi  '29.9999999999731 
Note  

Rounding errors, as discussed later, affect these examples. With infinite precision, the previous example would result in an answer of 30 degrees rather than 29.9999999999731.

The answer is roughly 30 degrees. The triangle in Figure 1 is used to help explain the trigonometric functions.

Compatibility  

Visual Basic .NET uses a different name and method to access the trigonometric functions as shown in Table 2 .

The trigonometric functions supported by OOo Basic are shown in Table 2 and illustrated using the right triangle in Figure 1. The single argument expression is converted to a double-precision number before the function is performed.

  • COS(x) = Adjacent Leg / Hypotenuse

  • SIN(x) = Opposite Leg / Hypotenuse

  • TAN(x) = Opposite Leg / Adjacent Leg = SIN(x) / COS(x)

  • ATN(Opposite Leg / Adjacent Leg) = x

The code in Listing 1 golves a series of geometry problems using the trigonometric functions. The code assumes a right triangle, as shown in Figure 1, with an opposite leg of length 3, and an adjacent leg of length 4. The tangent is easily calculated as 3/4 and the ATN function is used to determine the angle. A few other calculations are performed, such as determining the length of the hypotenuse using both the SIN and the COS functions. Also see Figure 2 .

click to expand
Figure 2: Use the trigonometric functions to solve problems with triangles.
Listing 1: Example Trigonmetric is found in the Array module in this chapter's source code files as SC03.sxw.
start example
 Sub ExampleTrigonmetric   Dim OppositeLeg As Double   Dim AdjacentLeg As Double   Dim Hypotenuse As Double   Dim AngleInRadians As Double   Dim AngleInDegrees As Double   Dim s As String   OppositeLeg = 3   AdjacentLeg = 4   AngleInRadians = ATN(3/4)   AngleInDegrees = AngleInRadians * 180 / Pi   s = "Opposite Leg = " & OppositeLeg & CHR$(10) &_       "Adjacent Leg = " & AdjacentLeg & CHR$(10) &_       "Angle in degrees from ATN = " & AngleInDegrees & CHR$(10) &_       "Hypotenuse from COS = " & AdjacentLeg/COS(AngleInRadians) & CHR$(10) &_       "Hypotenuse from SIN = " & OppositeLeg/SIN(AngleInRadians) & CHR$(10) &_       "Opposite Leg from TAN = " & AdjacentLeg * TAN(AngleInRadians)   MsgBox s, 0, "Trigonmentric Functions" End Sub 
end example
 



OpenOffice.org Macros Explained
OpenOffice.org Macros Explained
ISBN: 1930919514
EAN: 2147483647
Year: 2004
Pages: 203

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net