double atan2(double dY, double dX);
float atan2(float, float); double atan2(double, double); long double atan2(long double, long double);
float atan2f(float, float); long double atan2l(long double, long double);
* Note: Since C does not allow function overloading, these other versions of this function exist.
|
Domain (-∞, ∞) x (-∞, ∞) Range (-Π, Π] Periodicity None Symmetry None Asymptotes None |
#include <iostream>
#include <cmath>
int main() {
using namespace std;
// Point in the first quadrant
double dX = 4.3;
double dY = 5.3;
cout << "x = " << dX << " y = " << dY << " atan2(y, x) = " << atan2(dY, dX) << endl;
// Point in the second quadrant
dX = -12.2;
dY = 6.0;
cout << "x = " << dX << " y = " << dY << " atan2(y, x) = " << atan2(dY, dX) << endl;
// Point in the third quadrant
dX = -4.0;
dY = -3.0;
cout << "x = " << dX <<
" y = " << dY <<
" atan2(y, x) = " << atan2(dY, dX) << endl;
// Point in the fourth quadrant
dX = 2.8;
dY = -1.0;
cout << "x = " << dX << " y = " << dY << " atan2(y, x) = " << atan2(dY, dX) << endl;
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.