开发者

Object quaternion parallel or perpendicular to all basis vectors

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 ve开发者_JAVA百科ctors.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜