I am struggling with this in JavaScript, but this problem applies to many other languages/environments as well.
I want to have one object rotating towards the position o
The values are the same in both cases, modulo 2*PI, and with an adjustment for the different sign and offset convention. Pseudo-code:
2*PI
theta = 0.5*M_PI - atan2(y, x); // adjust for required sign/offset theta = fmod(theta, 2.0*M_PI); // make result modulo 2*PI