This function will calculate the sine of an angle.
Note: This function works with DOUBLE, but can also work with FLOAT as described in the Floating-point math introductory section.
Input:
V : DOUBLE
Angle expressed in radians.
Returns: DOUBLE
The sine of the angle.
Declaration:
FUNCTION sin : 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;
|