Everything

atan2 / atan2f / atan2l


Calculates the arc tangent of the division of two floating-point numbers.

[Format]

#include <math.h>

double atan2 (double y, double x);

float atan2f (float y, float x);

long double atan2l (long double y, long double x);

[Parameters]

x Divisor

y Dividend

[Return values]

Normal: Arc tangent value when y is divided by x

Abnormal: Domain error: Returns not-a-number.

[Remarks]

A domain error occurs if the values of both x and y are 0.0.

The atan2 function returns the arc tangent in the range (–π, +π) by the radian. The meaning of the atan2 function is illustrated in Figure 7.1. As shown in the figure, the result of the atan2 function is the angle between the X-axis and a straight line passing through the origin and point (x, y).

If y = 0.0 and x is negative, the result is π. If x = 0.0, the result is ±π/2, depending on whether y is positive or negative.

Figure 7.1

Meaning of atan2 Function