C Reference function atan2()

Usage of atan2():

double atan2(double y, double x);

Parameters:

Both y and x cannot be zero.

Return value:

Arc tangent in radians of y/x based on the signs of both values
to determine the correct quadrant. The returned value is in the range of -p/2 to +p/2 (inclusive).

Source code example of atan2():


#include<stdio.h>
#include<math.h>

#define PI 3.14159265

main()
{
	double x,y,output;
	x = 20.0;
	y = 20.0;
	output = atan2 (y,x) * 180 / PI;
	printf ("Arc tangent for x=%lf, y=%lf is %lf degrees\n", x, y, output);
	return 0;
}

Output of the atan2 example program above:


	Arc tangent for x=20.00000, y=20.00000 is 45.00000 degrees

This entry was posted in C Reference math.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.