Trigonometric Functions

 

Each of the trigonometric function below returns a numeric value and can be used where ever a numeric value is appropriate. Note that arguments representing angles (i.e., arguments to sin, cos, cot, and tan) must be in radians. The functions returning angles (i.e., arcsin, arccos, arccot, and arctan) return angles in radians. The examples below show some ways these functions can be used. Of course, actual Raptor programs may use different functions in different ways to achieve the programmer's desired functionality.

 

In Assignments:

x_sin <- sin(x)

x_sin <- sqrt(1.0 - cos(x)^2)

 

In Select and Loop Exit Comparisons:

arcsin(x) > 0.0

arccos(x) <= pi / 2.0

sin(x) > 0.0 and cos(x) < 0.0

 

Other places where functions can be used include output boxes (when a value is output) and as arguments to calls.

 

The unit circle figure below shows the radian measures for some angles.

 

 

Below are descriptions of the trigonometric functions.

SIN

variable <- sin(expression_in_radians)

 

sin returns the sine of the provided argument representing an angle in radians. For example, sin(pi/6) is 0.5, and sin(pi) is 0.

COS

variable <- cos(expression_in_radians)

 

cos returns the cosine of the provided argument representing an angle in radians. For example, cos(pi/3) is 0.5, and cos(pi) is -1.

TAN

variable <- tan(expression_in_radians)

 

tan returns the tangent (sine / cosine) of the provided argument representing an angle in radians. For example, tan(pi/4) is 1, and tan(pi) is 0. Note that a run-time error will occur if the cosine of the given argument is 0.

COT

variable <- cot(expression_in_radians)

 

cot returns the cotangent (cosine / sine) of the provided argument representing an angle in radians. For example, cot(pi/4) is 1, and cot(pi) is 0. Note that a run-time error will occur if the sine of the given argument is 0.

ARCSIN

variable <- arcsin(expression)

 

arcsin returns (in radians) the angle between -pi/2 and pi/2 whose sine is the argument. For example, arcsin(0.5) is pi/6, and arcsin(0) is 0.

ARCCOS

variable <- arccos(expression)

 

arccos returns (in radians) the angle between 0 and pi whose cosine is the argument. For example, arccos(0.5) is pi/3, and arccos(-1) is pi.

ARCCOT

variable <- arccot(x,y)

 

arccot returns (in radians) the angle between -pi and pi whose cotangent is x/y. The angle will be in the correct quadrant based on the signs of x and y. For example, arccot(sqrt(2)/2,sqrt(2)/2) is pi/4, arccot(-sqrt(2)/2,sqrt(2)/2) is 3/4 *pi, arccot(sqrt(2)/2,-sqrt(2)/2) is -pi/4, and arccot(-sqrt(2)/2,-sqrt(2)/2) is -3/4 *pi.

ARCTAN

variable <- arctan(y,x)

 

arctan returns (in radians) the angle between -pi and pi whose tangent is y/x. The angle will be in the correct quadrant based on the signs of y and x. For example, arctan(sqrt(2)/2,sqrt(2)/2) is pi/4, arctan(-sqrt(2)/2,sqrt(2)/2) is -pi/4, arctan(sqrt(2)/2,-sqrt(2)/2) is 3/4*pi, and arctan(-sqrt(2)/2,-sqrt(2)/2) is -3/4 *pi.