对象四元数平行或垂直于所有基向量

发布于 2024-09-15 09:22:51 字数 415 浏览 0 评论 0原文

给定一个对象四元数 q 和形成 3D 空间的基向量 vx、vy、vz,如何检查四元数是否平行或垂直于所有基向量?

例如,我有基向量:

vx = (0.447410, 0, -0.894329)
vy = (0, 1, 0)
vz = (0.894329, 0, 0.447410)

和四元数

q(w,x,y,z) = (-0.973224, 0, -0.229860, 0)

我知道四元数与所有基向量垂直或平行(或反平行),但我如何实际计算它?

另一个例子,

q(w,x,y,z) = (0.823991, 0, 0.566602, 0)

这不垂直或平行(或反平行)于所有基向量。

Given an object quaternion q, and basis vectors vx, vy, vz forming a 3D space, how can I check whether the quaternion is parallel or perpendicular to all of the basis vectors?

For example, I have basis vectors:

vx = (0.447410, 0, -0.894329)
vy = (0, 1, 0)
vz = (0.894329, 0, 0.447410)

and quaternion

q(w,x,y,z) = (-0.973224, 0, -0.229860, 0)

I know the quaternion is perpendicular or parallel (or anti-parallel) to all of the basis vectors but how can I actually calculate it?

Another example,

q(w,x,y,z) = (0.823991, 0, 0.566602, 0)

This is NOT perpendicular or parallel (or anti-parallel) to all of the basis vectors.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枫以 2024-09-22 09:22:51

关于术语的注释:严格来说,目前尚不清楚“四元数垂直于其中一个基向量”的确切含义……四元数和 3-D 向量不具有可比性。然而,四元数可以被认为是旋转轴(3-D 向量)和标量旋转角度的表示,所以我假设您想知道是否
旋转轴垂直于基向量之一。

对于被视为 3-D 旋转的单位四元数,约定是 q=(w,x,y,z),
x、y、z 沿着旋转轴形成一个 3 维向量(我们称之为 qv),w=cos(alpha/2) 表示旋转角度 alpha。

在您的情况下,qv = (x,y,z) = (0, -0.229860, 0)。 vx、vy 和 vz 都是单位向量,
因此,如果将 qv 归一化为单位向量,就更容易看出发生了什么。
除以其长度 (0.229860) 即可得到 qv_unit = (0, -1, 0)。寻找
qv_unit 与 vx、vy 和 vz 之间的角度,使用点积:

对于单位向量 v1=(a, b, c) 和 v2=(d, e, f):

cos(theta) = v1 dot v2 = ad + be + cf

qv_unit dot vx = 0*.447410 + -1*0 + 0*-894329 = 0 = cos(theta),因此 theta=pi/2,并且
我们看到 qv_unit 垂直于 vx。

qv_unit dot vy = 0*0 + -1*1 + 0*0 = -1 = cos(theta),所以 theta=pi,qv_unit 为
与 vy 反平行。

qv_unit dot vz = 0*.894329 + -1*0 + 0*.447410 = 0 = cos(theta),因此 theta=pi/2,并且
qv_unit 也垂直于 vz。

A note about terminology: Strictly speaking, it's not clear exactly what you mean by "the quaternion is perpendicular to one of the basis vectors"...quaternions and 3-D vectors are not comparable that way. However, quaternions can be thought of as a representation of a rotation axis (3-D vector) and a scalar rotation angle, so I'll assume you want to know if
the rotation axis is perpendicular to one of the basis vectors.

For unit quaternions considered as 3-D rotations, the convention is that for q=(w,x,y,z),
x, y, and z form a 3-D vector (let's call it qv) along the rotation axis, and w=cos(alpha/2) represents the rotation angle alpha.

In your case, qv = (x,y,z) = (0, -0.229860, 0). vx, vy, and vz are all unit vectors,
so it's easier to see what's going on if you normalize qv to also be a unit vector.
Divide through by its length (0.229860) to get qv_unit = (0, -1, 0). To find
the angles between qv_unit and vx, vy, and vz, use the dot product:

For unit vectors v1=(a, b, c) and v2=(d, e, f):

cos(theta) = v1 dot v2 = ad + be + cf

qv_unit dot vx = 0*.447410 + -1*0 + 0*-894329 = 0 = cos(theta), so theta=pi/2, and
we see that qv_unit is perpendicular to vx.

qv_unit dot vy = 0*0 + -1*1 + 0*0 = -1 = cos(theta), so theta=pi, and qv_unit is
anti-parallel to vy.

qv_unit dot vz = 0*.894329 + -1*0 + 0*.447410 = 0 = cos(theta), so theta=pi/2, and
qv_unit is also perpendicular to vz.

渔村楼浪 2024-09-22 09:22:51

我通过将四元数转换为矩阵解决了这个问题。从矩阵中取出基向量,并计算矩阵基向量与原始基向量之间的点积。如果它们都是0或1,则四元数与原始基向量平行或垂直。

I solved this by converting the quaternion to matrix. Taking the basis vectors from the matrix, and calculating the dot products between the matrix basis vectors and the original basis vectors. If they all are 0 or 1, the quaternion is parallel or perpendicular to the original basis vectors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文