Arc Tangent 2 Function

temp

Summary

Given the coordinates of a point, returns the angle associated with the point in radians. If the point’s -coordinate is negative the function returns a negative angle.

Syntax

Arguments

Name Description
y The vertical coordinate of the point.
x The horizontal coordinate of the point.

How to use

The improved arc tangent function takes in a and coordinate as input and returns the angle associated with the point . For example, given the point as input the function returns the angle of . This is illustrated by figure below.

Arc Tangent of the Point (1,1).
= atan2( 1, 1) =  0.785... // (1/8)*TAU

ATAN2 vs. ATAN

Many programming languages provide both the function and the function. The difference between the two functions is the range of possible return values for real number input. The range of is while the range of is . In other words, the atan function returns angles on the right half of the circle and atan2 returns angles on the whole circle.

Input Behavior
Quadrant 1 Same
Quadrant 2 Different
Quadrant 3 Different
Quadrant 4 Same

The different behavior is visualized below in the second quadrant when given the same point as input. The atan2 function returns the corresponding angle that is greater than a perpendicular while the atan function returns the corresponding angle that is less than a perpendicular angle.

atan2 vs atan

One way to reconcile the difference between the two functions is to extend the input of atan to accept numbers in the complex number system. In this case, the atan function will return angles on the full circle.