SpinConv converts from a rotation representation type to another. It supports the following rotation representation types:
• Rotation matrix
• Euler angles (including Tait-Bryan angles, a.k.a Cardan angles)
• Axis-angle (rotation about a single axis represented by an Euler vector)
SpinConv does the same job as SpinCalc by John Fuller (MATLAB Central file #20696). The results are identical, or equivalent, as you can check yourself by calling
Negligible output differences may be produced by rounding errors, because multiplications are sometimes executed in a different order.
SpinConv is a different implementation of the same algorithms, basically exploiting vectorized indices instead of loops, to perform iterative computations. In some cases, the new implementation is much faster. For instance, when the number of rotations to be converted (N) is very large, the conversion from DCM to EV is performed about 30 times faster. In some other cases, however, SpinConv may be slightly slower, expecially when N=1. For details about execution time for all kinds of conversion, just run
SpinConv also fixes a few bugs or inconsistencies that are present in version 1.3 of SpinCalc, including a non-standard output range for Euler Angles (in some cases larger than 180 degrees), not consistent with the imposed constraint for the corresponding input range (see input and output ranges below). Some of these bug fixes require additional computations (for instance, the instruction ANY used in the Boolean condition of some IF statements) and partly explain the slight increase in execution time that is observed in some cases.
CONVENTIONS AND CONSTRAINTS
All representation types accepted as input and returned as output by SpinConv are meant to represent the rotation of a 3D coordinate system (CS) relative to a rigid body or vector space ("alias" transformation), rather than vice-versa ("alibi" transformation).
DCMs (also known as rotation matrices) are special orthogonal matrices with determinant 1. Each matrix R contains in its rows the versors of the rotated CS represented in the original CS, and in its columns the versors of the original CS represented in the rotated CS. This format is typically used when the column-vector convention is adopted: point coordinates are arranged in column vectors v_i, and the desired rotation is applied by pre-multiplying v_i by R:
rotated v_i = R v_i.
With row vectors, the same rotation can be obtained by post-multiplying by the transpose of R:
rotated v_i = v_i RT.
“EA” type (Euler angles) includes both proper Euler angles (1st and 3rd rotation about the same axis) and Tait-Bryan angles (rotations about three distinct axes).
Both Euler vectors and quaternions are unit vectors.
• Second Euler angle must be -90 < theta < 90 degrees (theta = -90 and theta = 90 are not allowed).
• Second Tait-Bryan angle must be 0 < theta < 180 degrees (theta = 0 and theta = 180 are not allowed).
• All other angles may have any value, in degrees.
• Euler angles (psi, theta, phi) range from -90 to 90 degrees
• Tait-Bryan angles (psi, theta, phi) range from 0 to 180 degrees
• Angles about Euler vectors range from 0 to 180 degrees
Paolo de Leva (2023). SpinConv (https://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!