Skip to content

Add Quaternion constructor from real scalar and imaginary vector

Adds a constructor for Quaternions from a real part as a scalar and an imaginary part as a 3-vector. This new ctor makes it much easier to write common expressions like the angular velocity formula

\dot{\mathbf{q}} = \frac{1}{2} \mathbf{q} \otimes \begin{bmatrix} \boldsymbol{\omega} \\ 0 \end{bmatrix}

perturbation quaternions

\delta\mathbf{q} = \begin{bmatrix}\frac{1}{2}\delta\boldsymbol{\phi} \\ 1 \end{bmatrix}

and even the basic quaternion action on point formula (which is implemented as the test case that covers this new ctor)

\begin{bmatrix}\mathbf{v}_{new} \\ 0\end{bmatrix} = \mathbf{q} \otimes \begin{bmatrix}\mathbf{v} \\ 0 \end{bmatrix} \otimes \mathbf{q}^*

whereas when current users need to construct the scalar-vector quaternions in the expressions above, they must either write Eigen::Quaternion(re, im.x(), im.y(), im.z()), or default construct a mutable quaternion and set it using w() and vec().

Merge request reports

Loading