Quaternions, torque, and impulse. In a physics simulation I have a solid ball of mass $m$ and moment of interia $M$ (which is a diagonal matrix with all entries equal to ${2\over5}mr^2=i$). Its instantaneous rotation is given by a quaternion $q$.
This body is touching another rotating body which applys a force $f$ at a point $p$ measured from the centre of the ball. $f$ resolves into a push into the radius (which we can disregard here) and a tangential torque $f^T$.
The simulation advances in a time step of $t$ seconds. How should I update $q$?
I have a basic understanding of quaternions but not enough familiarity to approach this. Computational efficiency matters so I'd like to avoid converting $q$ into a matrix and back again. I imagine that $f^T$ and $p$ combine to some kind of "impulse" rotation $r_t$ so I can just do $q \to qr_t$. Is this at all the right way to do it?
 A: I don't know the term "instantaneous rotation", so I don't know whether you mean the instantaneous orientation or the instantaneous angular momentum or angular velocity; whichever one you mean, the other one seems to be missing from your state description. I also don't know what to make of a force resolving into a push and a torque, since a torque doesn't have the same dimensions as a force. Further it's unclear to me what you mean by "$f^T$ and $p$ combine", since $f^T$ is a force or a torque and $p$ is a point. I'll restate the problem in a form and notation that I understand, and I hope you'll be able to map that onto what you're doing.
The orientation of the body at time $t$ can be described by a quaternion $s(t)$ corresponding to the rotation required to get to that orientation from some reference orientation. Its rotational state can be described by either its angular momentum $L$ or its angular velocity $\omega$; since the body is symmetric and its moment of inertia $I=\frac25mr^2$ is a scalar, these two are proportional to each other, $L=I\omega$. The angular velocity can be regarded as an element of the Lie algebra of the quaternions, specified by a three-dimensional vector whose direction is the instantaneous axis of rotation and whose magnitude is the instantaneous angular speed. The body's orientation evolves according to $\dot s(t)=\Omega(t)s(t)$, where the dot denotes differentiation with respect to the time $t$ and $\Omega(t)=(0,\omega(t))$ is the purely imaginary quaternion corresponding to the angular velocity $\omega(t)$. In the absence of torques, the angular velocity is constant and the motion can be integrated to $s(t)=\exp(\omega t)s(0)$, where $\exp$ is the exponential map from the Lie algebra to the quaternions,
$$\exp(x)=\left(\cos|x|,\sin|x|\frac x{|x|}\right)\;.$$
A torque is by definition a rate of change of the angular momentum. A force $F$ acting at a point $p$ exerts a torque $\tau=r\times F$ on the ball, where $r$ is the vector from the ball's centre to $p$. This causes the angular momentum to change according to $\dot L=\tau$, so the angular velocity changes according to $\dot\omega=\tau/I$. Section $3$ of this paper gives what might be called a closed form for the resulting motion, but it's rather complicated and I gather you want to approximate the motion in finite time steps $\Delta t$. Since $\omega$ changes linearly, its update is exactly given by $\omega(t+\Delta t)=\omega(t)+\Delta t\tau/I$. To update the orientation $s$, you could take the average angular velocity $\bar\omega=\omega(t+\Delta t/2)=\omega(t)+\Delta t\tau/(2I)$ during the time step and update $s$ according to $s(t+\Delta t)\approx\exp(\bar\omega\Delta t)s(t)$. If you want, you can also approximate the exponential map by
$$
\exp(x)\approx\left(\sqrt{1-|x|^2},x\right)
$$
for small time steps.
I hope you can translate that into how you're thinking about the problem; if not, feel free to ask.
