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

旧街凉风 提交于 2019-12-02 05:00:51

问题


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 greater then 180. I'm using C++ but it is not really important because I need to get the theory.

This is what I am using now


回答1:


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.



来源:https://stackoverflow.com/questions/15054593/how-to-find-out-if-the-angle-between-two-vectors-is-external-or-internal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!