<?xml version="1.0" encoding="utf-8"?>

<UserFunctionMgr>
   <UserFunction
       Expression="(*&#10;Compute the angle from (0,0)&#13;&#10;*)&#10;&#10;FUNCTION ATAN2 : REAL&#10;&#9;VAR_INPUT&#10;&#9;&#9;x : REAL;&#10;&#9;&#9;y : REAL;&#10;&#9;END_VAR&#10;&#13;&#10;&#9;IF ( x &gt; 0.0 ) THEN&#13;&#10;&#9;&#9;// x &gt; 0&#13;&#10;&#9;&#9;ATAN2 := ATAN(y/x);&#13;&#10;&#9;ELSEIF ( x &lt; 0.0 ) THEN&#13;&#10;&#9;&#9;// x &lt; 0&#13;&#10;&#9;&#9;IF ( y &lt; 0.0 ) THEN&#13;&#10;&#9;&#9;&#9;// x &lt; 0, y &lt; 0&#13;&#10;&#9;&#9;&#9;ATAN2 := ATAN(y/x) - M_PI;&#13;&#10;&#9;&#9;ELSE&#13;&#10;&#9;&#9;&#9;// x &lt; 0, y &gt;= 0&#13;&#10;&#9;&#9;&#9;ATAN2 := ATAN(y/x) + M_PI;&#13;&#10;&#9;&#9;END_IF&#13;&#10;&#9;ELSE&#13;&#10;&#9;&#9;// x = 0&#13;&#10;&#9;&#9;IF ( y &lt; 0.0 ) THEN&#13;&#10;&#9;&#9;&#9;// x = 0, y &lt; 0&#13;&#10;&#9;&#9;&#9;ATAN2 := -(M_PI/2.0);&#13;&#10;&#9;&#9;ELSEIF ( y &gt; 0.0 ) THEN&#13;&#10;&#9;&#9;&#9;// x = 0, y &gt; 0&#13;&#10;&#9;&#9;&#9;ATAN2 := M_PI/2.0;&#13;&#10;&#9;&#9;ELSE&#13;&#10;&#9;&#9;&#9;// x = 0, y = 0 (undefined!)&#13;&#10;&#9;&#9;&#9;ATAN2 := 0.0;&#13;&#10;&#9;&#9;END_IF&#13;&#10;&#13;&#10;&#9;END_IF&#10;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#10;Compute the sine of an angle in degrees.&#13;&#10;*)&#10;&#10;FUNCTION SIN_DEG : REAL&#10;&#9;VAR_INPUT&#10;&#9;&#9;degree : REAL;&#10;&#9;END_VAR&#10;&#10;&#9;SIN_DEG := SIN(degree * (M_PI/180.0));&#10;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#10;Compute the cosine of an angle in degrees.&#13;&#10;*)&#10;&#10;FUNCTION COS_DEG : REAL&#10;&#9;VAR_INPUT&#10;&#9;&#9;degree : REAL;&#10;&#9;END_VAR&#10;&#10;&#9;COS_DEG := COS(degree * (M_PI/180.0));&#10;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#10;Compute the tangent of an angle in degrees.&#13;&#10;*)&#10;&#10;FUNCTION TAN_DEG : REAL&#10;&#9;VAR_INPUT&#10;&#9;&#9;degree : REAL;&#10;&#9;END_VAR&#10;&#10;&#9;TAN_DEG := TAN(degree * (M_PI/180.0));&#10;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#10;Compute the arc sine of an angle in degrees.&#13;&#10;*)&#10;&#10;FUNCTION ASIN_DEG : REAL&#10;&#9;VAR_INPUT&#10;&#9;&#9;x : REAL;&#10;&#9;END_VAR&#10;&#10;&#9;ASIN_DEG := ASIN(x) * (180.0/M_PI);&#10;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#13;&#10;Compute the arc cosine of an angle in degrees.&#13;&#10;*)&#13;&#10;&#13;&#10;FUNCTION ACOS_DEG : REAL&#13;&#10;&#9;VAR_INPUT&#13;&#10;&#9;&#9;x : REAL;&#13;&#10;&#9;END_VAR&#13;&#10;&#13;&#10;&#9;ACOS_DEG := ACOS(x) * (180.0/M_PI);&#13;&#10;&#13;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#13;&#10;Compute the arc cosine of an angle in degrees.&#13;&#10;*)&#13;&#10;&#13;&#10;FUNCTION ATAN_DEG : REAL&#13;&#10;&#9;VAR_INPUT&#13;&#10;&#9;&#9;x : REAL;&#13;&#10;&#9;END_VAR&#13;&#10;&#13;&#10;&#9;ATAN_DEG := ATAN(x) * (180.0/M_PI);&#13;&#10;&#13;&#10;END_FUNCTION"/>
   <UserFunction
       Expression="(*&#10;Compute the angle (in degrees) from (0,0)&#13;&#10;*)&#10;&#10;FUNCTION ATAN2_DEG : REAL&#10;&#9;VAR_INPUT&#10;&#9;&#9;x : REAL;&#10;&#9;&#9;y : REAL;&#10;&#9;END_VAR&#10;&#13;&#10;&#9;ATAN2_DEG := ATAN2(x, y) * (180.0/M_PI);&#13;&#10;&#13;&#10;END_FUNCTION"/>
</UserFunctionMgr>
