Quaternions – Exponential Map, Rotations, and Interpolation

algebra-precalculuscomplex-analysisgeometryquaternionsrotations

A code snippet I need to optimize is performing something peculiar. It seems that it's somehow related to transforming from a frame of reference to another. This is what it does, in mathematical terms:

$ \mathfrak{q}_{prevToCurrExpMap} = \exp ( \mathfrak{q}_{PrevToCurr} ) $

then

$ \mathfrak{q}_{prevToCurrExpMap} = \mathfrak{q}_{prevToCurrExpMap} + \mathfrak{q}_{rotationInduction}$

and finally

$ \mathfrak{q}_{prevToCurr} = \ln (\mathfrak{q}_{prevToCurrExpMap} ) $

Essentially, the orientation quaternion's exponential map is altered by a quaternion addition, and then the result is extracted by taking the logarithm. I am trying to understand the logic behind this piece of "code", but nothing comes to mind.

Is there any obvious reason for replacing a quat $\mathfrak{q}$ with $\ln(\exp(\mathfrak{q}) + \mathfrak{p})$? (at a first glance, it does not seem to encode any kind of interpolation, but it might be trickier than it appears.)

Best Answer

The Lie algebra to the Lie group of unit quaternions is the tangent space at $1$, i.e., the set of purely imaginary quaternions. The exponential map can then be written as $$ \exp(d)=\cos(\|d\|)+\frac{d}{\|d\|}\sin(\|d\|) $$ The corresponding parametrization at any other unit quaternion $q$ is then $$ q\cdot \exp(d)=q⋅\cos(\|d\|)+\frac{q⋅d}{\|d\|}\sin(\|d\|) $$ Note that $q⋅d$ is an element of the tangent plane at $q$ to the unit sphere, and $\|q⋅d\|=\|d\|$, so that the formula might be rewritten in terms of elements of the tangent plane.


One interpretation of the procedure in the question (exchanging ln and exp as suggested in the comments) is that a quaternion is first cast into the tangent plane of $1$ by decomposing $$ \mathfrak{q}_{prev}=\cos\alpha+\sin\alpha\,\vec n $$ using $c=Re(\mathfrak{q}_{prev})$, $\vec n'=Im(\mathfrak{q}_{prev})$, $\alpha=atan2(\|\vec n'\|,c)$, $\vec n=\vec n'/\|\vec n'\|$ and finally using $$\mathfrak{q}_{prevlog}=\alpha\vec n.$$

Then add the update vector and transform back using the exponential. One might keep the primary variables in the tangent plane if no modification happens in the exponential form, so that the logarithm transform is not necessary in every update step.

Related Question