How to calculate total full rotations? Imagine a diver. 
In his diver he goes through different orientations. Lets represent his rotation as $R(t)$ which might be represented as a quaternion.
He starts at one orientation and lets say he ends in the same orientation. So if he starts at $t=0$ and ends at $t=1$ then $R(0)=R(1)$.
Given we know all the values of $R$ from 0..1. How can one calculate how many somersaults he has done?
It should be presumably be some functional of $R(t)$. 
I believe it should be some topological quantity on the space of orientations.
Also, can one calculate how many sideways somersaults, and full twists he does?
If we split the time into finite chunks (such as seconds) and we know the orientation at each time slice and presume that the diver make the minimal change to his orientation can we easily calculate the number of somersaults?
 A: I use the convention that a quaternion $q$ is a formal sum $a+\mathbf{v}$ of a scalar component $a$ and a vector component $\mathbf{v}$, which we may also call the real and imaginary parts. Then $|a+\mathbf{v}|^2=|a|^2+\|\mathbf{v}\|^2$ gives us its norm, and we can multiply $(a+\mathbf{v})(b+\mathbf{w})$ using the distributive property followed by the formula for the scalar and vector components $\mathbf{vw}=-\mathbf{v}\cdot\mathbf{w}+\mathbf{v}\times\mathbf{w}$. The inner product is given by $\langle a+\mathbf{v},b+\mathbf{w}\rangle=ab+\mathbf{v}\cdot\mathbf{w}$. Multiplying by a unit vector on the left or right is an isometry with respect to this inner product. 
Note then that every quaternion $q$ has a polar form $q=r\exp(\theta\mathbf{v})$ for some $r\ge0$, phase $\theta$ and unit vector $\mathbf{v}$, and Euler's formula $\exp(\theta\mathbf{u})=\cos(\theta)+\sin(\theta)\mathbf{u}$ holds as usual. Moreover, if we conjugate a vector $\mathbf{u}$ by the quaternion $q$, the result $q\mathbf{u}q^{-1}$ will be the vector $\mathbf{u}$ rotated around the oriented axis $\mathbf{v}$ by $2\theta$ (in a counterclockwise direction).
Let's use $\mathbf{L},\mathbf{H},\mathbf{F}$ to describe the orthonormal frame in which $\mathbf{L}$ points left (from the point of view of the gymnast), $\mathbf{H}$ points up out of the gymnast's head, and $\mathbf{F}$ points in the direction that their face is facing. So we have $\mathbf{L}(t)=q(t)\mathbf{L}(0)q(t)^{-1}$ and similarly for $\mathbf{H}(t)$ and $\mathbf{F}(t)$.
Note that the infinitessimal rotation $\frac{d}{dt}q(t)\mathbf{u}q(t)^{-1}=\dot{q}(t)\mathbf{u}-\mathbf{u}\dot{q}(t)=2\mathbf{\dot{q}}(t)\times\mathbf{u}$ where $\mathbf{\dot{q}}(t)$ is the vector component of the derivative $\dot{q}(t)$. So, "locally" the person is rotating around the axis $\mathbf{\dot{q}}(t)$ at time $t$, at a speed proportional to the magnitude $\|\mathbf{\dot{q}}(t)\|$.
If a gymnast is performing a perfectly aligned somersault, then $\mathbf{L}(t)$ is constant and she is rotating around that axis, in which case the quantity $\mathbf{\dot{q}}(t)$ is $\mathbf{L}$. Similarly, if the gymnast is performing a perfectly aligned sideways-somersault (clockwise from their perspective), $\mathbf{F}(t)$ is constant and $\mathbf{\dot{q}}(t)$ will be $\mathbf{F}$, or if the gymnast is performing a perfectly aligned twist then $\mathbf{H}(t)$ will be constant and $\mathbf{\dot{q}}(t)$ will be $\mathbf{H}$. Actually $\mathbf{\dot{q}}(t)$ will only be these vectors up to a positive scalar dependent on the speed. So we can decompose $\mathbf{\dot{q}}(t)$ into components with respect to the $\mathbf{LFH}$ frame and integrate in order to measure somersault, sideways somersault and twisting.
In particular, the measure of somersaulting done from time $t=a$ to time $t=b$ is
$$ \int_a^b \mathbf{\dot{q}}(\tau)\cdot \mathbf{L}(\tau)\,\mathrm{d}\tau=\int_a^b \mathbf{\dot{q}}(\tau)\cdot q(\tau)\mathbf{L}(0)q(\tau)^{-1}\,\mathrm{d}\tau=\int_a^b q(\tau)^{-1}\mathbf{\dot{q}(\tau)}q(\tau)\,\mathrm{d}\tau\cdot\mathbf{L}(0). $$
This suggests we should define a quantity, let's call it tilt, by the integral
$$ \mathbf{T}=\int_a^b q(t)^{-1}\mathbf{\dot{q}}(t)q(t)\,\mathrm{d}t = \mathrm{Im}\left(\int_a^b q(t)^{-1}\dot{q}(t)q(t)\,\mathrm{d}t\right) $$
and then we have:


*

*the measure of somersaulting is $\mathbf{T}\cdot\mathbf{L}(0)$, 

*the measure of sideways somersaulting is $\mathbf{T}\cdot\mathbf{F}(0)$ and

*the measure of twisting is $\mathbf{T}\cdot\mathbf{H}(0)$.


Hopefully this is an appropriate way to measure what we want to measure. If so, there's probably already a physics word for this, like angular something or other.
