C examples for math.h:atan2
function
<cmath> <ctgmath> <math.h>
Compute arc tangent with two parameters
long double atan2l(long double y, long double x); long double atan2(long double y, long double x); double atan2(double y, double x); float atan2f(float y, float x); float atan2(float y, float x); double atan2(Type1 y, Type2 x);
Parameter | Description |
---|---|
y | Value representing the proportion of the y-coordinate. |
x | Value representing the proportion of the x-coordinate. |
If both arguments passed are zero, a domain error occurs.
Principal arc tangent of y/x, in the interval [-pi,+pi] radians. One radian is equivalent to 180/PI degrees.
#include <stdio.h> #include <math.h> /* atan2 */ #define PI 3.14159265/*from w w w. ja v a2s . co m*/ int main () { double x = -10.0; double y = 6.0; double result = atan2 (y,x) * 180 / PI; printf ("The arc tangent for (x=%f, y=%f) is %f degrees\n", x, y, result ); return 0; }