If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Course: Unlisted resources area > Unit 2

Lesson 1: ProcessingJS documentation

atan2(y, x)

Calculates the angle from a specified point to the coordinate origin as measured from the positive x-axis. When angleMode is "degrees" (the default), the values returned range from -180 to 180. When angleMode is "radians", the values returned range from -PI to PI.
This function is most often used for orienting geometry to the position of the cursor. Note that the y-coordinate of the point is the first parameter and the x-coordinate is the second due the the structure of calculating the tangent.
Parameters:
NameDescription
yThe y-coordinate of the point
xThe x-coordinate of the point

Want to join the conversation?

No posts yet.