Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors
SpinCalc is a consolidated matlab function that will convert any rotation data between the 4 types included. Will also convert between 2 different Euler angle set types.
Multiple orientations can be input. For N orientations:
DCM ===> 3x3xN multidimensional array
EA### ===> Nx3 matrix
Euler Vectors ===> Nx4 matrix
Quaternions ===> Nx4 matrix
Input includes error check flag that will warn when Euler angles approach singularity or when appropriate values deviate from unity. Fatal errors issued for improper DCM's etc.
*****NOTE TO USERS*****
I have gotten many questions regarding translation to Euler angle sets. When converting data to Euler angles, you MUST make sure the orientation you are translating is not near a singularity. Singular Euler sets are orientations which cannot be uniquely converted to 3 variables in that particular rotation order. The singular sets are as follows:
Type 1 Rotations: 123 - 132 - 213 - 231 - 321 - 312
Singular if second rotation angle is -90 or 90 degrees.
Type 2 Rotations: 121 - 131 - 212 - 232 - 313 - 323
Singular if second rotation angle is 0 or 180 degrees.
SpinCalc should now detect when input DCM, EV, or Q correspond to a singular Euler set output. It will prohibit output in such an event.
Naturally when converting from these singular Euler angle sets to other data types, you will receive a correct answer. Unfortunately you cannot convert that output back to the correct Euler angle set. This is why singular Euler input is prohibited.
Some users may need SpinCalc for the very reason of converting singular Euler sets to the other types. In those cases, removing the prohibiting error check shouldn't be too difficult. Contact me for help if need be.
Cite As
John Fuller (2024). Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors (https://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Robotics and Autonomous Systems > Robotics System Toolbox > Coordinate Transformations >
- Aerospace and Defense > Aerospace Toolbox > Standard Workflow Procedures > Physical and Time Unit Conversions >
- Aerospace and Defense > Aerospace Toolbox > Standard Workflow Procedures > Coordinate Systems > Quaternion Math >
Tags
Acknowledgements
Inspired: Euler angle, DCM, Quaternion, and Euler Vector Conversion/Teaching GUI, quaternion , SpinConv
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.11.0.0 | Incorporated fix to 2nd Euler Angle checks. |
||
1.10.0.0 | Updated help text. Again. |
||
1.9.0.0 | Updated help text to clarify DCM convention. |
||
1.8.0.0 | Fixed summary. |
||
1.7.0.0 | Updated description. |
||
1.6.0.0 | Updated tags |
||
1.5.0.0 | Updated tags |
||
1.4.0.0 | Modified v1.3 description |
||
1.3.0.0 | Version 1.3 Now detects when input DCM, Q, or EV are too close to Euler singularity. Prohibits output to Euler angles when second angle is within 0.1 degree of singular value. |
||
1.2.0.0 | Revised file description to explain Euler angle singularities |
||
1.1.0.0 | Removed bounding constraints on first and third input Euler angles. Bounds on second angles remain intact due to possibilities of ambiguous input Euler sets. |
||
1.0.0.0 | Updated file to version 1.1 to accommodate some user comments that improve output. |