求向量之间的符号角
你如何找到从向量 a 到 b 的符号角 theta?
是的,我知道 theta = arccos((ab)/(|a||b|))。
然而,它不包含符号(即它不区分顺时针或逆时针旋转)。
我需要一些可以告诉我从 a 到 b 旋转的最小角度的东西。正号表示从 +x 轴向 +y 轴旋转。相反,负号表示从+x轴向-y轴旋转。
assert angle((1,0),(0,1)) == pi/2.
assert angle((0,1),(1,0)) == -pi/2.
How would you find the signed angle theta from vector a to b?
And yes, I know that theta = arccos((a.b)/(|a||b|)).
However, this does not contain a sign (i.e. it doesn't distinguish between a clockwise or counterclockwise rotation).
I need something that can tell me the minimum angle to rotate from a to b. A positive sign indicates a rotation from +x-axis towards +y-axis. Conversely, a negative sign indicates a rotation from +x-axis towards -y-axis.
assert angle((1,0),(0,1)) == pi/2.
assert angle((0,1),(1,0)) == -pi/2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你想要使用的通常被称为“perp点积”,即找到垂直于其中一个向量的向量,然后找到与另一个向量的点积。
您还可以这样做:
What you want to use is often called the “perp dot product”, that is, find the vector perpendicular to one of the vectors, and then find the dot product with the other vector.
You can also do this:
如果您选择的数学库中有 atan2() 函数:
If you have an atan2() function in your math library of choice: