两个向量之间没有参考平面的符号夹角 [英] Signed angle between two vectors without a reference plane
问题描述
signed_angle(x_dir,y_dir)== 90
signed_angle(y_dir,x_dir)== 90
我希望第二个结果是否定的。这是由于跨产品 cross(x_dir,y_dir)
与 cross(y_dir,x_dir)
给定以下带有标准化输入的psuedocode:
pre $ signed_angle(Va,Vb)
magnitude = acos (点(Va,Vb))
轴=交叉(Va,Vb)
dir =点(Vb,cross(axis,Va))
if dir< 0 then
magnitude = -magnitude
endif
return magnitude
我不相信dir永远不会是负面的。
我看到了与建议的atan2解决方案相同的问题。
我正在寻找一种方法:
signed_angle(a,b)== -signed_angle( b,a)
谢谢大家。在回顾了这里的评论并回顾我正在尝试做的事情之后,我意识到我可以完成我需要做的与给定的标准公式有关的符号角度。我刚刚在单元测试中挂了我的签名角度函数。
作为参考,我将得到的角度反馈回旋转函数。我没有考虑到这样一个事实,即它自然会使用与signed_angle(输入矢量的叉积)相同的轴,并且正确的旋转方向将遵循该轴正面对的哪个方向。
更简单地说,这两者应该只是做正确的事情并向不同方向旋转:
rotate(cross(Vb,Va),signed_angle(Vb,Va),point)
其中第一个参数是旋转轴,第二个参数是旋转量。
(In three dimensions) I'm looking for a way to compute the signed angle between two vectors, given no information other than those vectors. As answered in this question, it is simple enough to compute the signed angle given the normal of a plane to which the vectors are perpendicular. But I can find no way to do this without that value. It's obvious that the cross product of two vectors produces such a normal, but I've run into the following contradiction using the answer above:
signed_angle(x_dir, y_dir) == 90
signed_angle(y_dir, x_dir) == 90
where I would expect the second result to be negative. This is due to the fact that the cross product cross(x_dir, y_dir)
is in the opposite direction of cross(y_dir, x_dir)
, given the following psuedocode with normalized input:
signed_angle(Va, Vb)
magnitude = acos(dot(Va, Vb))
axis = cross(Va, Vb)
dir = dot(Vb, cross(axis, Va))
if dir < 0 then
magnitude = -magnitude
endif
return magnitude
I don't believe dir will ever be negative above.
I've seen the same problem with the suggested atan2 solution.
I'm looking for a way to make:
signed_angle(a, b) == -signed_angle(b, a)
Thanks all. After reviewing the comments here and looking back at what I was trying to do, I realized that I can accomplish what I need to do with the given, standard formula for a signed angle. I just got hung up in the unit test for my signed angle function.
For reference, I'm feeding the resulting angle back into a rotate function. I had failed to account for the fact that this will naturally use the same axis as in signed_angle (the cross product of input vectors), and the correct direction of rotation will follow from which ever direction that axis is facing.
More simply put, both of these should just "do the right thing" and rotate in different directions:
rotate(cross(Va, Vb), signed_angle(Va, Vb), point)
rotate(cross(Vb, Va), signed_angle(Vb, Va), point)
Where the first argument is the axis of rotation and second is the amount to rotate.
这篇关于两个向量之间没有参考平面的符号夹角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!