同一平面内具有相同原点的两个 3D 矢量之间的有符号角 [英] Signed angle between two 3D vectors with same origin within the same plane

查看:20
本文介绍了同一平面内具有相同原点的两个 3D 矢量之间的有符号角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是位于同一 3D 平面内并具有相同原点的两个向量 Va 和 Vb 之间的带符号旋转角,知道:

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:

  1. 包含两个向量的平面是任意的,不平行于 XY 或任何其他基本平面
  2. Vn - 是平面法线
  3. 两个向量以及法线具有相同的原点 O = { 0, 0, 0 }
  4. Va - 是在 Vn 处测量左手旋转的参考

角度应该这样测量,如果平面是 XY 平面,那么 Va 将代表它的 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.

我想我应该通过使用 Va 作为 X 轴和 Vb 和 Vn 的叉积作为 Y 轴来执行一种坐标空间变换,然后只使用一些 2d 方法,比如 atan2() 或其他东西.有任何想法吗?公式?

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?

推荐答案

用两个向量的叉积得到两个向量所形成平面的法线.然后检查它和原始平面法线之间的点积,看它们是否面向同一方向.

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 矢量之间的有符号角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆