# Quaternion derivative

1. Jul 8, 2009

### nburo

Hello everyone.

Here's a unit rotation quaternion :

$$q(t) = [cos\frac{\theta(t)}{2} , \hat{u}(t)\cdot sin\frac{\theta(t)}{2}]$$

We know that if $$\hat{u}(t)$$ is constant, then our quaternion's derivative should be :

$$\dot{q}(t) = \frac{1}{2}\cdot q_\omega(t)\cdot q(t)$$

But what if $$\hat{u}(t)$$ wasn't constant? What would it look like? Same thing?

2. Jul 8, 2009

### tiny-tim

Hello nburo!

(have a û for copy-and-pasting )

No, you'd have to apply the chain rule, including the derivative of û(t).

(And of course û is a unit vector, so û.û = 1, so û.û' = 0, ie û' is always perpendicular to û. )

3. Jul 9, 2009

### nburo

Hello tiny-tim! =)

I prefer LaTeX =P

First of all, thanks for answering.

So would it look like this?

$$\dot{q}(t) = [-sin\frac{\theta(t)}{2} \cdot \frac{\dot{\theta}(t)}{2} , \dot{\hat{u}}(t)\cdot sin\frac{\theta(t)}{2} + \hat{u}(t)\cdot cos\frac{\theta(t)}{2}\cdot \frac{\dot{\theta}(t)}{2}]$$

So

$$\dot{q}(t) = [-\frac{1}{2}\cdot \omega(t)\cdot sin\frac{\theta(t)}{2} , \dot{\hat{u}}(t)\cdot sin\frac{\theta(t)}{2} + \frac{1}{2}\cdot \hat{u}(t)\cdot \omega(t) \cdot cos\frac{\theta(t)}{2}]$$

And $$\dot{\theta} = \omega$$ only if $$\theta$$ isn't constant.

So, if I'm not wrong, I am a bit confused. Since $$\omega$$ should be a vector, but it also appears into the scalar part, which doesn't work. I must be wrong... I mean, even if we say $$\hat{u}(t)$$ is constant, I don't even end up with the result I expected. And even if we modify the original quaternion to be

$$q(t) = [cos\frac{\Vert\theta(t)\Vert}{2} , \hat{u}(t)\cdot sin\frac{\Vert\theta(t)\Vert}{2}]$$

it doesn't seem to work either. Help =(

4. Jul 9, 2009

### tiny-tim

Hello nburo!

Why should ω be a vector?

I don't see anything wrong with that equation for q-dot.

Does this come from a problem about a specific quaternion rotation? ​

5. Jul 9, 2009

### nburo

Well, when we have $$\hat{u}(t)$$ constant :

$$\dot{q}(t) = \frac{1}{2}\cdot q_\omega(t)\cdot q(t)$$

Here $$q_\omega(t) = [0, \omega(t)]$$, that mean $$\omega(t)$$ should be a 3d-vector

Well, yes, but I don't think it should change anything. This quaternion $$q(t)$$ describes the motion of a rigid-body. Our $$\theta$$ should be the angle around $$\hat{u}(t)$$ which is $$u(t)$$ normalized. We also have an equation for $$u(t)$$, it's the equation of spherical interpolation given by :

$$p(t) = [0, u(t)] = \frac{sin(1-\frac{t}{T})\phi}{sin\phi}\cdot A + \frac{sin\frac{t}{T}\phi}{sin\phi}\cdot B$$

where t is time, T is the final time, $$\phi$$ is the angle between A and B. Finally, A and B are position quaternions on a unit sphere.

But I don't think this is relevant to find q-dot :P

Last edited: Jul 9, 2009
6. Jul 9, 2009

### tiny-tim

No, qω (t) = [0. ω(t)û] …

ω is a scalar, and only û is a vector.
ok, I think that means that û(t) traces out an arc of a circle between the positions of A and B. Putting one of the quaternion bases (k, say) at the centre of this circle would probably simplify things.

7. Jul 9, 2009

### nburo

You are very fast =) Thks again for helping

Oooh, that could make sense =) But would the û you put there be the same than the original one? Let's try :

$$\frac{1}{2}\cdot q_\omega(t)\cdot q(t) = \frac{1}{2}\cdot [0, \omega(t) \hat{u}]\cdot [cos\frac{\theta(t)}{2} , \hat{u}\cdot sin\frac{\theta(t)}{2}] = [0 - \omega(t)\cdot sin\frac{\theta(t)}{2} \cdot \hat{u}^2 , 0 + \hat{u}\cdot \omega(t) \cdot cos\frac{\theta(t)}{2} + \omega(t) \cdot sin\frac{\theta(t)}{2} \cdot (\hat{u}\times\hat{u}) ]$$

$$= \frac{1}{2}[- \omega(t)\cdot sin\frac{\theta(t)}{2} , \hat{u}\cdot \omega(t) \cdot cos\frac{\theta(t)}{2}] = \dot{q}(t)$$

Since the cross product of 2 identical vectors is 0. It works, thks!

How so?

EDIT : Be right back in 2 hours : take your time my friend =)

8. Jul 9, 2009

### tiny-tim

erm your job, not mine!

Try it and see! (I admit I haven't, but I think it'll work)

9. Jul 9, 2009

### nburo

I made a mistake earlier in my p(t) equation, I corrected. Now I'm trying the equation. I'll repost what I found later =)

10. Jul 9, 2009

### tiny-tim

Yes, I assumed that!

btw, I forgot to ask … what's φ? … it seems to have come from nowhere.

11. Jul 9, 2009

### nburo

=0

it's the angle between A and B! =)

12. Jul 9, 2009

### tiny-tim

ah, that makes more sense!

So if ê is the unit vector at the centre of the circle joining A and B,

then B = [cosφ/2, êsinφ/2]A

13. Jul 9, 2009

### nburo

=)

But that's only if we take the k base. We really don't know if our axis of rotation û will move this way around ê. Or maybe it doesn't change anything? Argh, I'm so confused

Anyways, I also derived p(t) :

$$\dot{p}(t) = \frac{\phi\cdot cos(\frac{t}{T}\phi)}{T\cdot sin\phi}B - \frac{\phi\cdot cos(\phi - \frac{t}{T}\phi)}{T\cdot sin\phi}A$$

Because A and B are constant vectors.

Also, in interpolation references, they use something like $$\tau = \frac{t}{T}$$ so Tau is between 0 and 1. But is it a good thing to substitute like I did to get p(t) in function of time?

14. Jul 9, 2009

### tiny-tim

What's the k base?

You said that these quaternions represent rotations of a rigid body …

that simply means that one of the bases (the first one) is the identity rotation

(and the other three can be any three perpendicular unit vectors).

All rotations are of that form.

15. Jul 9, 2009

### nburo

Haha =) I get it, sorry =P

Also, with B = [cosφ/2, êsinφ/2]A, does that mean I can simply substitute B by that in my main interpolation equation?

What about my time substitution in interpolation? Is it alright?

16. Jul 9, 2009

### tiny-tim

Yup!
Looks ok to me.

17. Jul 9, 2009

### nburo

You're one quaternion beast!

Before using our new equation, my research boss told me to do something.

David Baraff published some article in Siggraph '97. He developped a proof that even when û(t) is not constant, a quaternion time derivative can be expressed this way :

$$\dot{q}(t) = \frac{1}{2}\cdot q_\omega(t)\cdot q(t)$$

Remember? It's the time derivative for û as a constant! Well it seems to work when û(t) isn't constant too! Weird heh?

So I have to find an equation for $$q_\omega(t)$$ using this identity :

$$q_\omega(t) = 2 \cdot \dot{q}(t) \cdot q^*(t)$$

using a q(t) that has a u(t) that is described by an interpolation equation. My boss told me to start with a constant theta to see what would happen. I'm going to work on that. I will post my result if I get something interesting.

Thanks for all my friend!

18. Jul 9, 2009

### tiny-tim

David Baraff

ah! you mean (4-2) and Appendix B in http://www-2.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf and http://www-2.cs.cmu.edu/~baraff/sigcourse/notesd2.pdf

(btw, I forgot to mention … LaTeX will give you extra high brackets "to fit" if you type \left[ and \right] (you must use both) … also works for () {} and || )

Last edited by a moderator: Apr 24, 2017
19. Jul 10, 2009

### nburo

Re: David Baraff

WHAT???? You know that? WOW

Thks, but I already knew =) I was too lazy to type it, that's why :P I use LaTeX every at work. It's a so powerful tool!

Last edited by a moderator: Apr 24, 2017
20. Jul 11, 2009

### D H

Staff Emeritus
There is a lot of sloppiness of notation in this thread -- and in Baraff's lecture notes. There are four ways to write the time derivative of a unit quaternion, all variations on the theme

$$\dot{Q} = \frac 1 2 \begin{bmatrix} 0 \\ {\boldsymbol{\omega}} \end{bmatrix} Q$$

In various texts, you might see the right-hand side negated and you might see the order in which the two quaternion factors appear on the right-hand side switched. For example, I use

$$\dot{Q}_{A\to B} = -\,\frac 1 2 \begin{bmatrix} 0 \\ {\boldsymbol{\omega}_{A\to B:B}} \end{bmatrix} Q_{A\to B}$$

The reason for these variations include
• Whether the quaternion represents a rotation or a transformation.
I long ago learned to distinguish these concepts.
- Rotation: The physical rotation of some object.
- Transformation: Converting vectors from one reference frame to another.
Quaternions (and matrices, and any other chart on SO(3)), can be used to represent both concepts.

• The sense of the quaternion (e.g., inertial to body versus body to inertial).
The transformation matrix from frame B to A is the transpose of the transformation matrix from frame A to B. The same goes for quaternions, with conjugates instead of transposes.

• Left versus right quaternions.
Here are two ways to use a quaternion Q to rotate or transform a vector x:

\begin{aligned} \begin{bmatrix} 0 \\ \boldsymbol{x}_L \end{bmatrix} &= Q \begin{bmatrix} 0 \\ \boldsymbol{x} \end{bmatrix} Q^{\ast} \\ \begin{bmatrix}0 \\ \boldsymbol{x}_R \end{bmatrix} &= Q^{\ast} \begin{bmatrix} 0 \\ \boldsymbol{x} \end{bmatrix} Q \end{aligned}

The only difference between the two equations is whether the quaternion Q appears in unconjugated form to the left or to the right of the pure imaginary quaternion formed from the vector to be rotated / transformed.

• The frame in which the angular velocity is represented.
Most, but not all, people represent the angular velocity vector in the body frame.

With all the variations listed above, by not being careful about notation you might find yourself in a vehement argument with someone when in reality the two of you are in vehement agreement. I have intervened in such arguments more than once.

Last edited: Jun 6, 2012