问题描述
我需要的是旋转的两个向量Va和Vb处于同一3D平面内具有相同起源知道有符号的角度:
What I need is a signed angle of rotation between two vectors Va and Vb lying within the same 3D plane and having the same origin knowing that:
- 的平面contatining两种载体是任意和不平行于XY或任何其他基本平面的
- Vn的 - 是一个平面的法
- 与正常的两个向量具有相同的原点O = {0,0,0}
- 在弗吉尼亚州 - 是衡量左手旋转,速度Vn的 引用
的角度应以这样的方式来测量,所以如果在飞机将是XY平面上的弗吉尼亚将代表它的X轴单位向量。
The angle should be measured in such a way so if the plane would be XY plane the Va would stand for X axis unit vector of it.
我想我应该只是使用一些2D法像ATAN2使用VA作为X轴和Vb与Vn的交叉产品为Y轴,然后执行一种坐标空间变换()或东西。有任何想法吗?公式?
I guess I should perform a kind of coordinate space transformation by using the Va as the X-axis and the cross product of Vb and Vn as the Y-axis and then just using some 2d method like with atan2() or something. Any ideas? Formulas?
推荐答案
另外这两个载体使用跨产品,以获得正常的两个矢量形成的平面的。然后检查和正常原平面之间的dotproduct,看看他们都面临着同样的方向。
Use cross product of the two vectors to get the normal of the plane formed by the two vectors. Then check the dotproduct between that and the original plane normal to see if they are facing the same direction.
angle = acos(dotProduct(Va.normalize(), Vb.normalize()));
cross = crossProduct(Va, Vb);
if (dotProduct(Vn, cross) < 0) { // Or > 0
angle = -angle;
}
这篇关于在同一平面内有相同的起源两个3D向量签订角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!