The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Convetion of quaternion functions
Replies: 2   Last Post: Aug 13, 2014 1:49 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
William Frane

Posts: 36
Registered: 2/14/12
Convetion of quaternion functions
Posted: May 29, 2013 9:34 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

The various quaternion functions in the Aerospace Toolbox (see 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: Accordingly, if this quaternion is used to rotate the vector [1 1 1] in a right-handed 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 left-handed coordinate system, yet the documentation for the Aerospace Toolbox explicitly states that "[t]he Aerospace Toolbox software uses right-handed (RH) Cartesian coordinate systems" (see 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.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.