Calculates the arctangent of y/x.
double atan2( double y, double x )
The atan2 function returns the arctangent of y/x.
EX1
// This program computes and displays the arctangent of y/x. int test_atan2() { double vv; vv = atan2(2.5,2.5); out_double("atan2(2.5,2.5)=", vv); //output should be atan2(2.5,2.5)=0.7854 ASSERT( is_equal(vv, PI/4) ); vv = atan2(0,0); out_double("atan2(0,0)=", vv); //output should be atan2(0,0)=0 ASSERT( is_equal(vv, 0) ); vv = atan2(0,180000); out_double("atan2(0,180000)=", vv); //output should be atan2(0,180000)=0 ASSERT( is_equal(vv, 0) ); vv = atan2(0.0000023, 0); out_double("atan2(0.0000023, 0)=", vv); //output should be atan2(0.0000023, 0)=1.5708 ASSERT( is_equal(vv, PI/2) ); vv = atan2(-1234567,-2345677); out_double("atan2(-1234567,-2345677)=", vv); //output should be atan2(-1234567,-2345677)=-2.65711 ASSERT( is_equal(round(vv, 5), -2.65711) ); return 1; }
origin.h