Calculates the angle formed by a point, the origin, and the positive x-axis.
atan2()
is most often used for orienting geometry to the mouse's position, as in atan2(mouseY, mouseX)
. The first parameter is the point's y-coordinate and the second parameter is its x-coordinate.
By default, atan2()
returns values in the range -π (about -3.14) to π (3.14). If the angleMode() is DEGREES
, then values are returned in the range -180 to 180.
Examples
Syntax
atan2(y, x)
Parameters
y
Number:
y-coordinate of the point.
x
Number:
x-coordinate of the point.
Returns
Number: arc tangent of the given point.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/trigonometry.js and open a pull request!