0

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.

Dan Piponi
  • 4,406
Dims
  • 1,149

2 Answers2

4

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.

  • 1
    There are much better ways of doing this than the differential equation - the magical word to look for is 'SLERP' (Spherical Linear intERPolation), which offers an explicit formula in terms of $q_1$, $q_2$ and $t$ (and some trig functions) for a constant-velocity interpolation from $q_1$ to $q_2$. – Steven Stadnicki Jun 19 '14 at 23:08
  • The SLERP actually solves this differential equation. – Stefan Hante Jun 07 '17 at 12:43
1

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.

Ragnar
  • 6,233