atan2


atan2

Calculates the inverse tangent of a quotient

 #include <math.h> double atan2 ( double y , double x  ); float atan2f ( float y , float x  );         (C99) long double atan2l ( long double y , long double x  );         (C99) 

The atan2( ) function divides the first argument by the second and returns the arc tangent of the result, or arctan(y/x).

The return value is given in radians, and is in the range -p atan2(y,x) atan2( y,x) p/2 atan2( y,x) p atan2( y,x) -p/2 atan2( y,x) 0

Example

 /*  * Calculate an acute angle of a right triangle, given  * the adjacent and opposite sides.  */ #define PI 3.141593 #define DEG_PER_RAD (180.0/PI) double adjacent = 3.0; double opposite = 4.0; double angle = atan2( opposite, adjacent ) * DEG_PER_RAD; printf( "The acute angles of a 3-4-5 right triangle are %4.2f\xB0 "         "and %4.2f\xB0.\n", angle, 90.0 - angle ); 

This code produces the following output:

 The acute angles of a 3-4-5 right triangle are 53.13° and 36.87°. 

See Also

The arc tangent function for a single argument: atan( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net