Quaternion conventions differ from source to source, and in fact quaternions do not intrinsically have anything to do with rotations. Qrot Rotate the frame for a vector using a quaternion. Qpos Return the equivalent quaternions with positive scalar part. Qinv Invert a rotation quaternion (quaternion conjugate). Qinterpf Interpolate between quaternions, given a fraction from one to the other. Qinterp Interpolate between quaternions, given an independent variable. Qerr Calculate the rotation angle between two quaternions. Qdot Calculate the time derivative of a quaternion given a rotation rate. Qdiff Calculate the difference of a rotation quaternion wrt another. Qcomp Calculate rotation resulting from two quaternion rotations. Q2mrp Convert to the modified Rodrigues parameters. Q2ea Convert to Euler angles with the specified sequence. Q2dcm Convert to a direction cosine matrix. Q2aa Convert to axis-angle representation. However, this can be accomplished with the qpos function when necessary. No attempt is made to ensure that a quaternion is in its "positive" form (that the scalar part is positive). Note that quaternions q and -q refer to the same rotation, and this can be a useful property. In terms of the axis, r, and angle of rotation:Ĭlearly, is the identity rotation (no rotation). Perhaps the only drawback to quaternions is that they are not as intuitive for most people as Euler angles or direction cosine matrices. Functions for simulation and conversion between other rotation forms are included in this toolbox. For all of these reasons, quaternions are well suited to representing the orientation of a body over time in simulations. Further, their time derivatives are easy to calculate, and keeping a quaternion valid (with a unit 2-norm) is easy. Operations with quaternions are fast and generally stable. Rotation quaternions (Euler-Rodrigues symmetric parameters) can represent any rotation without singularity. Quaternions (Euler-Rodrigues Symmetric Parameters) Multiplying a DCM with a vector rotates the frame in which that vector is seen.ĭcm2ea Convert to Euler angles with the specified sequence.Įach column has a unit 2-norm, and the cross product of the first two columns yields the third column. Direction Cosine Matricesĭirection cosine matrices (rotation matrices) are the classic, unambiguous, and easy-to-use rotation representation. This can be most efficient, for instance, when only the angles are needed as an output the rotation axes need never be calculated. Of course, when the rotation angle is 0, then the rotation axis arbitrary any function that returns a rotation axis will use therefore use when the rotation angle is 0.Īa2dcm Convert to a direction cosine matrix.Īa2mrp Convert to modified Rodrigues parameters.Īa2q Convert to a rotation quaternion (Euler-Rodrigues symmetric parameters).Īashort Return the smallest angle of rotation and corresponding axis.Īll functions that accept or return axis-angle representations use the angle first and the axis second. That is, any rotation can be described as a single rotation about some fixed axis. For instance, to rotate a vector by 45 degrees around the y axis, we can use the transpose of the rotation matrix (the transpose of a rotation matrix is its inverse):Īll rotations can be specified as a unique, right-handed rotation axis and corresponding angle of rotation between 0 and 2*pi. Vector rotations are the opposite (inverses) of frame rotations. % We therefore expect the vector to appear on the positive x and z axes when viewed in frame B. % Frame B is rotated from frame A by a 45 degree rotation about the y axis. % In frame A, let's say the vector is aligned with the x axis. To see how the rotations rotate the viewpoint and not the vector, consider: That is, they rotate the viewpoint, not the thing being view. These are all discussed more below.Īll rotation operations correspond to frame rotations. Rotation types include direction cosine matrices, rotation quaternions (Euler-Rodrigues symmetric parameters), modified Rodrigues parameters, axis-angle representations, and Euler angles. The functions contain vectorized code for speed in MATLAB and code that generates good C code when used with Simulink or MATLAB Coder. This repository contains files for using 3D vectors and rotations in MATLAB.
0 Comments
Leave a Reply. |