Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Convetion of quaternion functions
Posted:
May 29, 2013 9:34 AM


The various quaternion functions in the Aerospace Toolbox (see http://www.mathworks.com/help/aerotbx/flightparameters1.html) all indicate that an input quaternion q should have "its scalar number as the first column" (i.e., [w x y z] ordering rather than [x y z w]). However, this convention doesn't always seem to produce the expected result.
For example, the quaternion [cos(pi/2) + 0i + 0j + sin(pi/2)] = [1/sqrt(2) + 0i + 0j + 1/sqrt(2)k] represents a rotation about the z axis ([0 0 1]) by 90 degrees (Wolfram Alpha confirms this: http://www.wolframalpha.com/input/?i=quaternion%3A+%281%2Fsqrt%282%29%29%2B0i%2B0j%2B%281%2Fsqrt%282%29%29k). Accordingly, if this quaternion is used to rotate the vector [1 1 1] in a righthanded coordinate system,, the result should be [1 1 1].
If MATLAB's quatrotate function is used to perform this rotation, the result is quatrotate([1/sqrt(2) 0 0 1/sqrt(2)], [1 1 1]) = [1 1 1] This result corresponds to a rotation about the z axis by 90 degrees, not 90 as expected.
Another example: rotating [0 0 1] by the quaternion [1/sqrt(2) 1/sqrt(2) 0 0] (which represents a 90 degree rotation about the x axis) yields quatrotate([1/sqrt(2) 1/sqrt(2) 0 0],[0 0 1]) = [0 1 0] when the expected result is [0 1 0].
The result from quatrotate (at least for these two examples) seems to be determined using a lefthanded coordinate system, yet the documentation for the Aerospace Toolbox explicitly states that "[t]he Aerospace Toolbox software uses righthanded (RH) Cartesian coordinate systems" (see http://www.mathworks.com/help/aerotbx/ug/definingcoordinatesystems.html#bqsgj4j5). Other quaternion functions exhibit similar behaviour (e.g., using the quaternion from the first example, quat2dcm produces a matrix that performs a 90 degree rotation about the z axis).
Have I missed a part of the documentation that explains this behaviour, or am I using these functions incorrectly? Any assistance would be appreciated.



