Time derivative of the blend of a pair of quaternion curves

70 Views Asked by At

I have two curves ${\bf q}_0(t), {\bf q}_1(t)$. Each curve maps time $t$ to a unit quaternion. Construction of these curves is not important here, although we do have the respective time derivatives for the curves given by $\dot{\bf q}_0(t), \dot{\bf q}_1(t)$. My goal is to find a unit quaternion and its time derivate of the two curves blended by some parameter $p \in [0, 1]$. Using a slerp for the blended unit quaternion gives ${\bf q} = {\bf q}_0 ({\bf q}^*_0 {\bf q}_1)^p$, where ${\bf q}^*$ is the quaternion conjugate, and ${\bf q}^p = e^{p \log({\bf q})}$. For the sake of this discussion, assume $p$ is not time dependent. It will be in the final solution but for now let's not be bothered by that.

My question is how to compute the time derivative $\dot{\bf q}$. Intuitively, it appears to be something of the form $\dot{\bf q} = ((1 - p)\dot{\bf q}_0{\bf q}^*_0 + p\dot{\bf q}_1 {\bf q}^*_1) {\bf q}$, which is linearly interpolated angular velocities times blend result. This formula obviously is correct for $p = 0$ and for $p = 1$. I'm trying to find some mathematical backing for the general case.

Naively, taking $\dot{\bf q} = \dot{\bf q}_0({\bf q}^*_0 {\bf q}_1)^p + {\bf q}_0 p ({\bf q}^*_0 {\bf q}_1)^{p - 1} (\dot{\bf q}^*_0 {\bf q}_1 + {\bf q}^*_0 \dot{\bf q}_1)$ can't be correct in the general case, since the product operator does not commute.

I could use some help in finding the proper time derivative. In particular, I would like to know whether there is a general formula for $\frac{d}{dt}{\bf q}(t)^p$, for constant $p \in [0, 1]$. Perhaps someone with a grasp of Lie groups/algebras could shed some light on this. Thanks for your help.

2

There are 2 best solutions below

1
On

You can write $\overline{q_0(t)}q_1(t)=\cos\theta(t)+\sin\theta(t)\,\mathbf{u}(t)$ where

$$ \theta(t)=\cos^{-1}\mathrm{Re}\big(\,\overline{q_0(t)}q_1(t)\big), \quad \mathbf{u}(t)=\frac{\mathrm{Im}\big(\,\overline{q_0(t)}q_1(t)\big)}{\|\mathrm{Im}\big(\,\overline{q_0(t)}q_1(t)\big)\|} $$

Then $(\overline{q_0}q_1)^p=\cos p\theta+\sin p\theta \,\mathbf{u}$, and you can differentiate from there. Of course you'll get possible continuity and ill-definedness issues whenever $q_1=\pm q_0$. I don't know what the context here is, but it might be possible to say $\overline{q_0}q_1=\exp(\mathbf{v})$ where $\mathbf{v}(t)$ is a 3D space curve (note $\mathbf{v}$ determines $\overline{q_0}q_1$ but not vice-versa, so in a sense $\mathbf{v}$ would be a more fundamental thing to know). If you go that route, you would still have to expand out $\exp(p\mathbf{v})$ with Euler's formula to differentiate, or else use the power series (and note the derivative of $\mathbf{v}(t)^n$ will have $n$ terms that are not "like" and don't combine).

0
On

Update (see my previous answer below): Sometimes the only way to see a solution is when it is screaming at you in the text you just wrote. The log lerp is a geodesic if the line through $\log({\bf q}_0)$ and $\log({\bf q}_1)$ contains the origin. One way to move the origin onto the line is by rotating the two quaternions by ${\bf q}^*_0$, putting $\log({\bf q}^*_0{\bf q}_0)$ at the origin). By performing the blend on the rotated quaternions, and then rotating the result back by ${\bf q}_0$, you get the original blend result ${\bf q} = {\bf q}_0\exp(p \log({\bf q}^*_0{\bf q}_1)) = {\bf q}_0 ({\bf q}^*_0{\bf q}_1)^p$.

The advantage of doing it this way wrt to method below, other than following a geodesic, is that now one of the Jacobians is at the origin, which is trivially the identity matrix. The Jacobian at $2 \log({\bf q}^*_0{\bf q}_1)$ is then used to find the time derivative in terms of the exponential map for $\dot{\bf q}_1$. The time derivate of the blend result $\dot{\bf q}$ can be found to be the Jacobian at $2 p\log({\bf q}^*_0{\bf q}_1)$ times the linearly interpolated velocities in exponential map coordinates.

Previous answer: I've found a solution that is not exactly an answer to my original question, yet workable in my case. Instead of blending using a slerp, I found that when blending by a lerp of exponential maps, ${\bf q} = \exp( (1 - p) \log({\bf q}_0) + p \log({\bf q}_1) )$, the corresponding time derivative $\dot{\bf q}$ is not too difficult to compute. Although this log lerp does not generally follow a geodesic curve on $S^3$, the blend behaves good enough for my purpose.

The angular velocity of the blend result at a given point in time is found by lerping the angular velocities after transforming them to the parameter space of the exponential map (both $\mathbb{R}^3$) using the right Jacobian for exponential coordinates (Chirikjian, Stochastic Models, Information Theory, and Lie Groups, volume 2, page 40).