5
$\begingroup$

I have to multiply two quaternions to calculate a so called spherical linear interpolation between two $R^3$ coordinate systems within the interval $t = [0, 1]$.

enter image description here

I understand how to do the calculation of quaternions basicly works and how to do the slerp. There is a lot of literature available.

But I don't know how to get started: How to create initial quaternions from given coordinate system axis and angles? I basicly fail to understand the meaning of quaternions I guess.

$\endgroup$
2
  • 1
    $\begingroup$ Usually we identify the quaternions $i,j,k$ with the canonical base for $\mathbb{R}^3$. So any point (or vector, if you prefer) in $\mathbb{R}^3$ can be written as $ai+bj+dk$ (the point $(a,b,c)$). $\endgroup$
    – Sigur
    Commented Jun 22, 2013 at 11:32
  • $\begingroup$ Wikipedia lists lots of conversion formulae between different rotation representations. If you have the initial and final coordinate axes, you can build the corresponding rotation matrix and then convert it to a quaternion. $\endgroup$
    – user856
    Commented Jun 22, 2013 at 13:53

3 Answers 3

0
$\begingroup$

In 3D space, initial coordinates are decided by the given Left-hand and Right-hand coordinates, sometimes called x-up, y-up, z-up conventions which can also be found (for example) in Wiki's EulerAngles item.

Initial Quaternions are defined corresponding to the intial x-y-z

For example, x-y-z-right hand coordinates, then 0,0,0,1 would be the initial quaternion.

Of course, the order also depends on the setting of program.

For example maybe DirectX and openGL are in different orders of the initial quaternion of the same coordinates.

And also your self programs could in one arbitrary initial order.

However, when one initial order was defined(corresponding to x-y-z), then the other 23 orders could also be well defined.

4!

(*
    24
*)

24 is the number of kinds of orders. When I decide which order was used in one 3D game engine which I cannot know the order by specification, I do experiments.

Maybe you could find a Matrix to Quaternion program, and then do rotations in Matrix, then convert the combined final matrix to Quaternions will lead you a good comprehension.

$\endgroup$
0
$\begingroup$

Okay, I think I got it. The quaternion is created like this:

$$q = \begin{pmatrix} a_x \cdot \sin{\frac{\alpha}{2}} \\ a_y \cdot \sin{\frac{\alpha}{2}} \\ a_z \cdot \sin{\frac{\alpha}{2}} \\ \cos{\frac{\alpha}{2}} \end{pmatrix}$$

I have one quaternion for each axis. Each axis is a vector (with three coordinates) and is aligned along a certain angle. That's six quaternions in total for two coordinate systems:

$$q_{x1} = \begin{pmatrix} \sin{\frac{\alpha_{x1}}{2}} \\ 0 \\ 0 \\ \cos{\frac{\alpha_{x1}}{2}} \end{pmatrix}, q_{y1} = \begin{pmatrix} 0 \\ \sin{\frac{\alpha_{y1}}{2}} \\ 0 \\ \cos{\frac{\alpha_{y1}}{2}} \end{pmatrix}, q_{z1} = \begin{pmatrix} 0 \\ 0 \\ \sin{\frac{\alpha_{z1}}{2}} \\ \cos{\frac{\alpha_{z1}}{2}} \end{pmatrix} $$

and

$$q_{x2} = \begin{pmatrix} \sin{\frac{\alpha_{x2}}{2}} \\ 0 \\ 0 \\ \cos{\frac{\alpha_{x2}}{2}} \end{pmatrix}, q_{y2} = \begin{pmatrix} 0 \\ \sin{\frac{\alpha_{y2}}{2}} \\ 0 \\ \cos{\frac{\alpha_{y2}}{2}} \end{pmatrix}, q_{z2} = \begin{pmatrix} 0 \\ 0 \\ \sin{\frac{\alpha_{z2}}{2}} \\ \cos{\frac{\alpha_{z2}}{2}} \end{pmatrix} $$

The quaternions above are normalized unit quaternions and already simplified, because for the x-axis $a_x = 1$, $a_y = 0$ and $a_z = 0$, and so on: $ a_x^2 + a_y^2 + a_z^2 = 1$.

$\endgroup$
0
$\begingroup$

Given 3 initial vectors $\hat x_0, \hat y_0, \hat z_0$ (pure imaginary quats) that describe the initial directions of the axes, the current direction of each axis can be found by

$$\hat x = q \hat x_0 q^{-1}$$

and so on. You shouldn't need to keep track of more than four quats at any time: 3 that describe the axes in one frame and $q$ to describe the overall rotation of the frame to another frame.

$\endgroup$

You must log in to answer this question.

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