Following [1], which has further useful information.
A quaternion is defined in terms of its scalar part
Addition is just component-wise, or can be interpreted as adding the scalar parts and adding the vectors with usual vector math:
In terms of three-dimensional vector operations, a quaternion product can be expressed as:
Conjugation negates the vector part:
The inverse of any quaternion is given by
so for unit quaternions, the inverse is the conjugate.
Given two quaternions
This is true when the difference quaternion
By Theorem 1 in [1], part 3:
If
$N(\mathbf{q}) = 1$ then$\mathbf{q} = (\cos\Omega, \hat{\mathbf{v}}\sin\Omega)$ acts to rotate around unit axis$\hat{\mathbf{v}}$ by$2\Omega$ .
To find
and, as noted,
a fact that we back out from the definition of
An explicit version of the quat log for any (non-unit) quaternion can be found in [2]:
Which is indeed a pure vector for unit quaternions.
[1] Quaternions - Ken Shoemake: https://campar.in.tum.de/twiki/pub/Chair/DwarfTutorial/quatut.pdf
[2] Notes on Quaternions - Simo Särkkä: https://users.aalto.fi/~ssarkka/pub/quat.pdf
Some handling of edge cases https://gepettoweb.laas.fr/doc/stack-of-tasks/pinocchio/master/doxygen-html/explog-quaternion_8hpp_source.html#l00084