ATN2()

Arcus tangent a sine and a cosine argument

Syntax

ATN2 (nSine, nCosine) -> nRadiant

Arguments

<nSine> the sine of an angle <nCosine> the cosine of an angle

Returns

<nRadiant> the angle whose tangent is <nSine>/<nCosine>

Description

The function ATN2() is an alternate function for calculating the arcus tangent, atn2(x,y) = atan(x/y). It takes two arguments, the sine and the cosine of the angle that should be calculated. Thus, in contrast to the ATAN() function, ATN2() can distinguish whether the sine or the cosine has a negative sign (or both being positive or negative), so that the return value can be between -PI() and PI() and covers the full angle. The return value is given in radiants (full angle equals 2*Pi - see DTOR() if you need to convert it into degress).
Examples
      ? atn2 (0.0, 1.0) --> 0.0
      ? atn2 (sqrt(1/2), sqrt(1/2)) --> PI()/4
Tests
      atn2 (0.0, 1.0) == 0.0
      atn2 (sqrt(1/2),sqrt(1/2)) == PI()/4
      atn2 (-sqrt(1/2),-sqrt(1/2)) == -3/4*PI()  // atan() would return PI()/4 !
Status

Ready

Compliance

ATN2() is compatible with CT3's ATN2().

Platforms

All

Files

Source is trig.c, library is libct.

See Also