I am new to processing but have done a bit of programming in the past. I was making a 2d game and I need a picture to face where the mouse is pointing. So for example the picture is the top down view of a man's head and his head should rotate depending on where the mouse is located (i.e. his eyes face the mouse).
I tried using tan to calculate the angle, but I got a weird result.
Here is my code (NOTE: only top right quarter of the screen can calculate the angle):