Smooth transition between two quaternions?

655 Views Asked by At

I am describing the orientation of an object with quaternion $q$. Now I want to describe (animate) smooth transition between orientations of $q_1$ and $q_2$. I was thinking that quaternion $q = q_1 (1-t) + q_2 t$ will do this, where $t$ varies in the range $0..1$.

Unfortunately, it was behaving differently.

In my case $q_1$ was zero rotation, i.e. $q_1=(0,0,0,1)$. After $t$ was reaching values of approximately $0.1 - 0.01$ (i.e. much less then $1$) the object was apparently at the final orientation of $q_2$.

Why? I mean is this mathematically correct? Probably this is because $q_1$ is zero direction and does not play any role and when $t$ reaches some significance, then $q_2$ affects the result.

If so, then how to obtain correct parametrized function $q(t)$ which describes smooth orientation change from $q_1$ to $q_2$?

UPDATE

My strange behaviour was explained by a bug in other part of the progran, so formula $q = q_1 (1-t) + q_2 t$ looks ok.

2

There are 2 best solutions below

2
On BEST ANSWER

When going from $a$ to $b$, you should do $$ x(t)=a+t(b-a)=(1-t)a+tb $$ Here, $a$ and $b$ can be anything, for example vectors or quaternions.

2
On

Every quaternion should be a unit vector, and in general your $q = (1-t)q_1 + tq_2$ will not be a unit vector.

At a minimum you would need to re-normalize for each $t$ of interest. However, if you really want to see it transition smoothly - you probably want to simulate the progress via the quaternion differential equation $\dot{q} = \frac{1}{2}q\cdot \omega$ where this dot represents a quaternion product (not a standard vector dot product).

An excellent reference for this is in this article or in this article.