This function will calculate the principal value of the arc tangent of an angle.
This function can not determine the quadrant of the angle. Use atan2 if it is needed.
Note: This function works with DOUBLE, but can also work with FLOAT as described in the Floating-point math introductory section.
Input:
V : DOUBLE
Value to compute the arc tangent of.
Returns: DOUBLE
The arch tangent of the value in radians.
Declaration:
FUNCTION atan : DOUBLE;
VAR_INPUT
v : DOUBLE;
END_VAR;
Example:
INCLUDE rtcu.inc
INCLUDE math.inc
PROGRAM test;
VAR
a : DOUBLE;
END_VAR;
a := cos(v:=0.4);
DebugMsg(message:=" cos " + doubleToStr(v := a));
DebugMsg(message:="acos " + doubleToStr(v := acos(v:=a)));
a := sin(v:=0.4);
DebugMsg(message:=" sin " + doubleToStr(v := a));
DebugMsg(message:="asin " + doubleToStr(v := asin(v:=a)));
a := tan(v:=0.4);
DebugMsg(message:=" tan " + doubleToStr(v := a));
DebugMsg(message:="atan " + doubleToStr(v := atan(v:=a)));
a := atan2(a:=10.0, b:= 10.0);
DebugMsg(message:="atan2 " + doubleToStr(v := a));
END_PROGRAM;
|