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 by p5.js Contributors and the Processing Foundation is licensed under CC BY-NC-SA 4.0.