How to find out if the angle between two vectors is external or internal?

后端 未结 1 1608
梦毁少年i
梦毁少年i 2021-01-21 11:07

I know how to find out angle between 2 vectors, but it always gives me internal angle, but I want it to give me always the angle in anticlockwise direction, even if it is greate

相关标签:
1条回答
  • 2021-01-21 11:19

    You're looking for the atan2(y,x) function (http://en.wikipedia.org/wiki/Atan2). If you give it the two components of a 2D vector, it will give you the angle of the vector from the x axis, in the counter-clockwise direction. To solve your specific problem try:

    atan2(v_y, v_x) - atan2(u_y, u_x)
    

    Then you can add or subtract 360 degrees if the answer is out of the range of angles you desire.

    0 讨论(0)
提交回复
热议问题