Angle between two lines is wrong

后端 未结 3 1041
执笔经年
执笔经年 2021-02-06 07:11

I want to get angles between two line. So I used this code.


int posX = (ScreenWidth) >> 1;

int posY = (ScreenHeight) >> 1;

double radians, de         


        
3条回答
  •  萌比男神i
    2021-02-06 07:59

    If you simply use

    radians = atan2f( y - posY , x - posX);
    

    you'll get the angle with the horizontal line y=posY (blue angle).

    enter image description here

    You'll need to add M_PI_2 to your radians value to get the correct result.

提交回复
热议问题