ATN2()

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 !

Compliance

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

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), COT(), ASIN(), ACOS(), ATAN(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()

2 responses to “ATN2()

  1. Pingback: Harbour All Functions – A | Viva Clipper !

  2. Pingback: Harbour Math Functions | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.