Freigeben über


atan, atan2 (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Calculates the arctangent of x (atan) or the arctangent of y/x (atan2).

double atan(doublex);double atan2(doubley, doublex);

Parameters

  • x, y
    Any numbers.

Return Values

atan returns the arctangent of x.

atan2 returns the arctangent of y/x.

If x is 0, atan returns 0.

If both parameters of atan2 are 0, the function returns 0.

atan returns a value in the range –π/2 to π/2 radians.

atan2 returns a value in the range –π to π radians, using the signs of both parameters to determine the quadrant of the return value.

Remarks

atan calculates the arctangent of x.

atan2 calculates the arctangent of y/x.

atan2 is well defined for every point other than the origin, even if x equals 0 and y does not equal 0.

Example

/* ATAN.C: This program calculates 
 * the arctangent of 1 and -1.
 */


void main( void ) 
{
   double x1, x2, y;

   printf( "Enter a real number: " );
   scanf( "%lf", &x1 );
   y = atan( x1 );
   printf( "Arctangent of %f: %f\n", x1, y );
   printf( "Enter a second real number: " );
   scanf( "%lf", &x2 );
   y = atan2( x1, x2 );
   printf( "Arctangent of %f / %f: %f\n", x1, x2, y ); 
}

Output

Enter a real number: -862.42
Arctangent of -862.420000: -1.569637
Enter a second real number: 78.5149
Arctangent of -862.420000 / 78.514900: -1.480006

Requirements

OS Versions: Windows CE 2.0 and later.
Header: stdlib.h.
Link Library: coredll.dll.

See Also

acos | asin | cos | sin | tan

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.