Quick Tip Code: Extracting a Vector From a Quaternion

Usually I am doing the opposite operation building an orient attribute from a set of vectors.

While that is second nature to me by now it wasn’t immediately obvious to me how to deconstruct the orient(quaternion) again without going back to a matrix first. Probably because my math foundation isn’t what it should be but once I realized what I needed to do it was very simple.

The answer to the problem is rotating an orthogonal vector with orient. In VEX terms that is the qrotate() fuction with a vector output and that is it you done, very easy indeed only one or two lines of code.
vector vec = set(0,0,1);
v@N = qrotate(@orient, vec);

Leave a Reply

Your email address will not be published. Required fields are marked *