quaternion_inverse

giant.rotations:

giant.rotations.quaternion_inverse(quaternion)[source]

This function provides the inverse of a rotation quaternion of the form discussed in Rotation Representations.

The inverse of a rotation quaternion is defined such that \(\mathbf{q}\otimes\mathbf{q}^{-1}=\mathbf{q}_I\) where \(\mathbf{q}_I=\left[\begin{array}{cccc}0&0&0&1\end{array}\right]^T\) is the identity quaternion which corresponds to the identity matrix (or no rotation) and \(\otimes\) indicates quaternion multiplication. Mathematically this corresponds to negating the vector portion of the quaternion:

\[\begin{split}\mathbf{q}=\left[\begin{array}{c}\text{sin}(\frac{\theta}{2})\hat{\mathbf{x}}\\ \text{cos}(\frac{\theta}{2})\end{array}\right]\\ \mathbf{q}^{-1}=\left[\begin{array}{c}-\text{sin}(\frac{\theta}{2})\hat{\mathbf{x}}\\ \text{cos}(\frac{\theta}{2})\end{array}\right]\end{split}\]

This function is also vectorized, meaning that you can specify multiple rotation quaternions to be inversed by specifying each quaternion as a column. Regardless of whether you are converting 1 or many quaternions the first axis must have a length of 4.

This function makes the output have the same number of dimensions as the input. Therefore, if the input is one dimensional, then the output is one dimensional, and if the input is two dimensional then the output will be two dimensional. In addition, if you supply this function with an Rotation object then this function will return an Rotation object of the inverse rotation.

Parameters:

quaternion (Sequence | ndarray | Rotation) – The rotation quaternion(s) to be inverted

Returns:

a numpy array or Rotation representing the inverse quaternion corresponding to the input quaternion

Return type:

ndarray | Rotation