In the C Programming Language, the atan2 function returns the arc tangent of y / x.
Syntax
The syntax for the atan2 function in the C Language is:
double atan2(double y, double x);
Parameters or Arguments
x The parameter when calculating the arc tangent of y / x. y The parameter when calculating the arc tangent of y / x.
Returns
The atan2 characteristic returns the arc tangent of y / x. It will return a value between -π and π. If x and y are each equal to 0, the atan2 function will return a area error.
Required Header
In the C Language, the required header for the atan2 characteristic is:
#include <math.h>
Applies To
In the C Language, the atan2 characteristic can be used in the following versions:
ANSI/ISO 9899-1990
atan2 Example
/* Example using atan2 by TechOnTheNet.com */
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[])
{
/* Define temporary variables */
double value1, value2;
double result;
/* Assign the two values we will find the atan2 of */
value1 = 0.5;
value2 = -0.5;
/* Calculate the Arc Tangent of value1 and value2 */
result = atan2(value1, value2);
/* Display the result of the calculation */
printf("The Arc Tangent of %f and %f is %f\n", value1, value2, result);
return 0;
}
When compiled and run, this utility will output:
The Arc Tangent of 0.500000 and -0.500000 is 2.356194
Similar Functions
Other C functions that are comparable to the atan2 function:
acos feature asin function atan feature cos feature sin feature tan function
Leave a Review