4
$\begingroup$

I have an application that tracks an image and estimates its position and orientation. The orientation is given by a quaternion, and it is modified by an angular velocity every frame.

To predict the orientation I calculate the differential quaternion basing on the angular rate $\vec \omega$ and the previous quaternion $\vec q$. I found these equations.

$$q_x=\frac{1}{2}(w_x q_w+w_y q_z-w_z q_y) $$ $$q_y=\frac{1}{2}(w_y q_w+w_z q_x-w_x q_z) $$ $$q_z=\frac{1}{2}(w_z q_w+w_x q_y-w_y1 q_x)$$ $$q_w=-\frac{1}{2}(w_x q_x+w_y q_y-w_z q_z)$$

Is this approach correct? Should I use $\vec \omega$ or do I need to take into account the time interval between frames $\vec \omega\Delta t $?

After this, the predicted quaternion $\hat q$ would be the sum of the previous one and the differentiation, wouldn't it?

$\endgroup$

3 Answers 3

5
$\begingroup$

The derivative of a function $q: \mathbb{R} \rightarrow \mathbb{H}$ representing a rotation with angular velocity $\omega: \mathbb{R} \rightarrow \mathbb{R}^3$ around some axis by unit quaternions is

$$ \frac{\mathrm{d}}{\mathrm{d}t}q(t) = \frac{1}{2} * (\omega_x(t) \mathrm{i} + \omega_y(t) \mathrm{j} + \omega_z(t) \mathrm{k}) * q(t),$$

where $q(t) = q_w(t) + q_x(t) \mathrm{i} + q_y(t) \mathrm{j} + q_z(t) \mathrm{k}$, $\omega(t) = \left(\begin{smallmatrix} \omega_x(t) \\ \omega_y(t) \\ \omega_z(t) \end{smallmatrix}\right)$ and $*$ represents the quaternion multiplication operator. A derivation can be found at Euclidean Space. By evaluating the quaternion multiplications the derivatives of the real and imaginary components of $q(t)$ can be identified to be

$$ \left(\begin{matrix}\frac{\mathrm{d}}{\mathrm{d}t} q_w(t) \\ \frac{\mathrm{d}}{\mathrm{d}t} q_x(t) \\ \frac{\mathrm{d}}{\mathrm{d}t} q_y(t) \\ \frac{\mathrm{d}}{\mathrm{d}t} q_z(t) \end{matrix}\right) = \frac{1}{2} \left[\begin{matrix} -q_x(t) & -q_y(t) & -q_z(t) \\ q_w(t) & q_z(t) & -q_y(t) \\ -q_z(t) & q_w(t) & q_x(t) \\ q_y(t) & -q_x(t) & q_w(t) \end{matrix} \right] \left(\begin{matrix} \omega_x(t) \\ \omega_y(t) \\ \omega_z(t) \end{matrix} \right).$$

Note that the left-hand sides of your equations miss the derivatives and the derivative of the real part $q_w(t)$ has a sign error. To numerically integrate these equations in time you need to discretize them. You can probably use a simple explicit Euler scheme for your purpose, where e.g.

$$ \frac{\mathrm{d}}{\mathrm{d}t} q_w(t) \approx \frac{q_w(t + \delta t) - q_w(t)}{\delta t}.$$

Thus to "predict" the orientation you can use

$$ \left(\begin{matrix}q_w(t+\delta t) \\ q_x(t+\delta t) \\ q_y(t+\delta t) \\ q_z(t+\delta t) \end{matrix}\right) = \left(\begin{matrix}q_w(t) \\ q_x(t) \\ q_y(t) \\ q_z(t) \end{matrix}\right) + \frac{1}{2} \delta t \left[\begin{matrix} -q_x(t) & -q_y(t) & -q_z(t) \\ q_w(t) & q_z(t) & -q_y(t) \\ -q_z(t) & q_w(t) & q_x(t) \\ q_y(t) & -q_x(t) & q_w(t) \end{matrix} \right] \left(\begin{matrix} \omega_x(t) \\ \omega_y(t) \\ \omega_z(t) \end{matrix} \right).$$

So if your equations are read as update formulas, then no they are not quite correct (see note above), yes you should take the time interval into account and yes you should add the previous quaternion. Also you need to make sure that you normalize your quaternion after updating since it can loose its unit length when numerically integrating it.

$\endgroup$
1
$\begingroup$

If you know both the orientation and the angular velocity at every frame, this paper on Hermite Quaternion Curves might be useful for interpolation, http://graphics.cs.cmu.edu/nsp/course/15-464/Fall05/papers/kimKimShin.pdf

However, curve derivative calculation is difficult/expensive with this approach.

$\endgroup$
0
$\begingroup$

Quaternion differentiation is achieved through the multiplication of a quaternion (e.g. a 4-dimensional potential) with a quaternion differential operator. Multiplication can be performed from the left side or from the right side; the results differ in the sign of the curl part. The quaternion differential of a vector potential is the analogue to the gradient of a scalar potential, but yielding a quaternion field comprising source and curl components, distinguished from each other by their symmetry. E.g.: the quaternion differential of the electrodynamic vector potential A yields (under Lorenz gauge) the electromagnetic field E+B. Formulas of quaternion differentiation

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .