Extracting basis vectors from a quaternion

Started by
12 comments, last by alvaro 8 years, 5 months ago

Code snippets like the above should definitely come with a comment disambiguating the used conventions. Inherently a quaternion (nor a matrix) does not have forward, right or up vectors, but it is the semantic conventions that give such meanings. What is 'Up' in one engine can be 'Forward' in the conventions of another engine. Quickly glancing, in the conventions used by the above snippet, the function ComputeRightVector is the image of (1,0,0) or +X vector when transformed (=conjugated) by the quaternion, and ComputeUpVector is the image of (0,1,0)/+Y vector, and ComputeForwardVector is the image of (0,0,1)/+Z vector transformed by the quaternion. The coordinate system is assumed to be left-handed. Were those the assumed conventions?

Advertisement

This is true, the coordinate system used was needed to be say.


Just take each of the identity basis vectors (1, 0, 0), (0, 1, 0) and (0, 0, 1) and rotate them with the quaternion.

Good luck on doing that without the quaternion's matrix.

Alundra- that is just an expanded routine of the actual quaternion to matrix conversion.

Good luck on doing that without the quaternion's matrix.


You don't need luck if you know what you are doing, or if you have the formulas I posted above in this very thread.

This topic is closed to new replies.

Advertisement