::

Cos(), Sin(), Tan(), ACos(), ASin(), ATan(), ATn2(), DToR(), RToD(), Pi()

Sines, sines,
everywhere there's sines,
breakin' up the scenery,
blowin' my mind
—with apologies to Five Man Electric Band

Okay, everyone remembers their high school trigonometry, right? No? We don't blame you. With any luck, you will never be called upon to write an app requiring these functions, but it's nice to know they're available should you need them.

All the functions describe angle in terms of radians, a unit of measure. (You might remember there are 2 times pi radian units in a circle, just as 360 degrees describes the circle.) If you need to convert your angles back and forth between the two numbering systems, the DTOR() and RTOD() functions allow you to switch back and forth between the units of measure. All functions properly respect nulls, returning null if any of their supplied parameters are null.

Usage

nRetValue = COS( nAngle ) nRetValue = SIN( nAngle ) nRetValue = TAN( nAngle )

Parameter

Value

Meaning

nAngle

Numeric

The angle to calculate, expressed in radians.

nRetValue

Numeric

The trigonometric value of the specified angle.


These three functions—sine, cosine and tangent—return the equivalent trigonometric functions.

Example
? COS(PI()/3)   && returns 0.50 ? SIN(PI()/3)   && returns 0.87 ? TAN(PI()/3)   && returns 1.73
Usage
nRetValue = ACOS( nTrigValue ) nRetValue = ASIN( nTrigValue ) nRetValue = ATAN( nTrigValue ) nRetValue = ATN2( nXValue, nYValue )

Parameter

Value

Meaning

nTrigValue

Numeric

The value returned from the trigonometric function.

nXValue, nYValue

Numeric

The X and Y coordinates of a point in any of the four quadrants describing a line through the origin. This line and the line y=0 form the angle returned by ATN2().

nRetValue

Numeric

The angle, in radians, whose trigonometric value is supplied to the function.


The "arc" functions (arcsine, arccosine and arctangent are inverse trigonometric functions) return what angle must have been supplied to their matching trigonometric functions (sine, cosine and tangent) to return the value supplied to them as a parameter. There are two arctangent functions—cleverly named ATAN() and ATN2()—to allow for two different ways of supplying the parameters: either the value of the tangent function, or the equivalent X and Y coordinates of the angle.

Example

? ACOS(.5)      && returns 1.047, or PI/3

Usage

nAngleInRadians = DTOR( nAngleInDegrees ) nAngleInDegrees = RTOD( nAngleInRadians )

Parameter

Value

Meaning

nAngleInDegrees

Numeric

The angle expressed in degrees.

nAngleInRadians

Numeric

The angle expressed in radians.


DTOR() and RTOD() convert degrees to radians and vice versa.

Example

? DTOR( 90 )        && returns 1.57, or PI/2 ? RTOD( PI() / 2 )  && returns 90

Usage

nRetValue = PI()
PI() returns the static value 3.1415...

Example

? PI()  && displays 3.1415...etc., depending on SET(DECIMALS)

View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

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