atan (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

3.10 / 1.00.00


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));
 
// Output:
//  cos 0.9210609916817709
// acos 0.4000000059604644
//  sin 0.3894183477986018
// asin 0.4000000059604644
//  tan 0.4227932257640837
// atan 0.4000000059604645
// atan2 0.7853981633974483
 
END_PROGRAM;