atan2

 

Description

Calculates the arctangent of y/x.

Syntax

double atan2( double y, double x )

Parameters

y
[input] Any numbers.
x
[input] Any numbers.

Return

The atan2 function returns the arctangent of y/x.

Examples

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;
}

Remark

See Also

header to Include

origin.h

Reference