Atan2() - C library function Program
Declaration :
1 |
double atan2(doubly y, double x) |
Explanation :
Purpose | The C library function double atan2(doubly y double x) returns the arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant. |
Parameters | x ===> This is the floating point value representing an x-coordinate. |
y ===> This is the floating point value representing an y-coordinate. | |
Return Value | This function returns the principal arc tangent of y/x in the interval [-pi+pi] radians. |
Exception |
C Program : Example
The following example shows the usage of atan2() function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, y, ret, val; x = -7.0; y = 7.0; val = 180.0 / PI; ret = atan2 (y,x) * val; printf("The arc tangent of x = %lf, y = %lf ", x, y); printf("is %lf degreesn", ret); return(0); } |