atan2
The atan2() method returns the arctangent of the quotient of its arguments (y/x), taking into account the signs of both arguments to determine the correct quadrant. Unlike atan(), it returns an angle between -π and π, covering all quadrants of the trigonometric circle.
Interactive example
Syntax
Classic signature
typescript
function atan2<
GenericAxisY extends number
>(
axisY: GenericAxisY,
axisX: number
): numberCurried signature
typescript
function atan2<
GenericAxisY extends number
>(
axisX: number
): (axisY: GenericAxisY) => numberParameters
axisY: The y coordinate (or vertical component, classic signature only).axisX: The x coordinate (or horizontal component).
Important note: The parameter order in the classic signature is axisY then axisX, which follows the standard mathematical convention atan2(y, x).
Return value
returns the angle in radians (between -π and π) between the positive x-axis and the point (axisX, axisY).
See also
atan- Calculates the arctangent (single quadrant)tan- Calculates the tangent of an anglesin- Calculates the sine of an anglecos- Calculates the cosine of an angle
