简体   繁体   English

如何确定两个向量之间的角度是外部还是内部?

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

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. 我知道如何找出两个矢量之间的角度,但它总是给我内部角度,但我希望它总是给我逆时针方向的角度,即使它大于180.我使用C ++但它不是非常重要因为我需要理论。

This is what I am using now 这就是我现在使用的 式

You're looking for the atan2(y,x) function ( http://en.wikipedia.org/wiki/Atan2 ). 您正在寻找atan2(y,x)函数( 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. 如果给它提供2D矢量的两个分量,它将以逆时针方向给出x轴的矢量角度。 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. 然后,如果答案超出了您想要的角度范围,您可以加上或减去360度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM