I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the atan2() function in the C++ programming as follows :
Code:
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main( int ac, char* av[] )
{
double z1, z2, z;
if( ac != 3 )
{
fprintf( stderr, "Usage: %s <z1> <z2>\n", av[0] );
return;
}
z1 = atof( av[1] );
z = atan( z1 );
printf( "Arctangent of %f: %f\n", z1, z );
z2 = atof( av[2] );
z = atan2( z1, z2 );
printf( "Arctangent of %f / %f: %f\n", z1, z2, z );
}
Output
Code:
Arctangent of 0.500000: 0.463648
Arctangent of 0.500000 / 5.000000: 0.099669
Bookmarks