quaternion_to_rotvec

giant.rotations:

giant.rotations.quaternion_to_rotvec(quaternion)[source]

This function converts a rotation quaternion into a rotation vector of the form discussed in Rotation Representations.

The rotation vector is returned as a numpy array and is formed by:

\[\begin{split}\theta = 2*\text{cos}^{-1}(q_s) \\ \hat{\mathbf{x}} = \frac{\mathbf{q}_v}{\text{sin}(\theta/2)} \\ \mathbf{v} = \theta\hat{\mathbf{x}}\end{split}\]

This function is also vectorized, meaning that you can specify multiple rotation quaternions to be converted to rotation vectors 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. It also checks for cases when theta is nearly zero (less than 1e-15) and replaces these with the identity rotation vector [0, 0, 0].

Parameters:

quaternion (Sequence | ndarray | Rotation) – the rotation quaternion(s) to be converted to the rotation vector(s)

Returns:

The rotation vector(s) corresponding to the input rotation quaternion(s)

Return type:

ndarray