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.
This page is generated from the comments in src/math/trigonometry.js . Please feel free to edit it and submit a pull request!