| 2.1.16.7.4 atan2
 DescriptionCalculates the arctangent of y/x.
 Syntaxdouble atan2( double y, double x ) Parameters y [input] Any numbers. x [input] Any numbers.
 ReturnThe atan2 function returns the arctangent of y/x.
 ExamplesEX1
 // 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;
}RemarkSee AlsoHeader to Includeorigin.h
 Reference |