Given the and coordinates of a point, returns the angle associated with the point in radians. If the point’s -coordinate is negative, meaning that the point is in quadrant or , the function returns a negative angle.
|y||A number representing the vertical component of a point in the Cartesian Plane|
|x||A number representing the horizontal component of a point in the Cartesian Plane|
The improved arctangent function, which takes in a and coordinate as input, returns the angle associated with the point . For example, given the point as input the function returns the angle of as illustrated by figure below..
= atan2(1,1) = 0.785... // (1/8)*TAU
Many programming languages provide both the ATAN2 function and the ATAN 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.
The reason why both functions exist has to do with the complex number system. When using complex number input with
ATAN the function returns angles in all coordinates. The difference is that
ATAN2 expects the horizontal and vertical components as separate values and
ATAN expects complex number input which has the two different components stored within one number.
So if you are not using the complex number system, this is the function to use in most cases. Otherwise, the other arc functions will work well with the complex number system.