Aim

The atan2() function calculates the angle between two positions. The angle it calculates can be used to rotate a shape toward something. In this example, the eyes rotate to look at the cursor.

Aim: Revised by Darren Kessner, Malay Vasa. Edited and maintained by p5.js Contributors and Processing Foundation. Licensed under CC BY-NC-SA 4.0.

You can find the code history of these examples here: pre-2023 example, 2023 code. You can suggest improvements by contributing to the current website!