Just use atan2 for calculating angles.

Atan2, I love you!