Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert a rotation matrix to an equivalent unit quaternion
ResourceFunction["RotationMatrixToQuaternion"][mat] converts the 3×3 rotation matrix mat into an equivalent unit quaternion. |
Generate a rotation matrix:
In[1]:= |
![]() |
Out[1]= |
![]() |
Convert to quaternion form:
In[2]:= |
![]() |
Out[2]= |
![]() |
A real matrix:
In[3]:= |
![]() |
Out[3]= |
![]() |
Convert to quaternion form:
In[4]:= |
![]() |
Out[4]= |
![]() |
An approximate MachinePrecision matrix:
In[5]:= |
![]() |
Out[5]= |
![]() |
In[6]:= |
![]() |
Out[6]= |
![]() |
An approximate arbitrary precision matrix:
In[7]:= |
![]() |
Out[7]= |
![]() |
In[8]:= |
![]() |
Out[8]= |
![]() |
Create a rotation matrix:
In[9]:= |
![]() |
Out[9]= |
![]() |
Also define a vector to be rotated:
In[10]:= |
![]() |
Out[10]= |
![]() |
Transform the vector using the rotation matrix representation:
In[11]:= |
![]() |
Out[11]= |
![]() |
Transform the vector using the quaternion representation of a rotation to get the same result:
In[12]:= |
![]() |
Out[12]= |
![]() |
Generate a matrix from a given set of Euler angles:
In[13]:= |
![]() |
Out[13]= |
![]() |
Convert to its quaternion representation:
In[14]:= |
![]() |
Out[14]= |
![]() |
Generate a matrix from a given set of roll-pitch-yaw angles:
In[15]:= |
![]() |
Out[15]= |
![]() |
Convert to its quaternion representation:
In[16]:= |
![]() |
Out[16]= |
![]() |
Generate a random rotation matrix:
In[17]:= |
![]() |
Out[17]= |
![]() |
Convert to its quaternion representation:
In[18]:= |
![]() |
Out[18]= |
![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License