Reference atan2()

atan2()

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

y-coordinate of the point.

x

x-coordinate of the point.

Notice any errors or typos? Please let us know. Please feel free to edit src/math/trigonometry.js and open a pull request!

Related References