Quaternion and three axes

Given the quaternion q and three three-dimensional vectors (vx, vy, vz), which form coordinate axes that can be oriented in an arbitrary direction, but all are perpendicular to each other, thus forming three-dimensional space.

How to check if the quaternion q rotates in the same direction (or in the opposite direction) as some of the three-dimensional vectors (vx, vy, vz)?

+4
source share
1 answer

If q = (w, x, y, z), where w is the “scalar part” and qv = (x, y, z) is the “vector part”, then you can calculate the angle between qv and each of the basis vectors vx , vy, vz using the point product.

cos (theta) = (qv dot vx) / (| qv | * | vx |)

If cos (theta) is +1, the axis of rotation q is parallel to this base vector.

cos (theta) = -1 means that they are antiparallel.

+3
source

All Articles