How to use atan2() in combination with other Radian angle systems

后端 未结 4 739
陌清茗
陌清茗 2021-02-04 18:46

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

4条回答
  •  庸人自扰
    2021-02-04 19:16

    The values are the same in both cases, modulo 2*PI, and with an adjustment for the different sign and offset convention. Pseudo-code:

    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
    

提交回复
热议问题