Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Quaternion derivative

  1. Jul 8, 2009 #1
    Hello everyone.

    Here's a unit rotation quaternion :

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

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

    [tex]\dot{q}(t) = \frac{1}{2}\cdot q_\omega(t)\cdot q(t)[/tex]

    But what if [tex]\hat{u}(t)[/tex] wasn't constant? What would it look like? Same thing?
  2. jcsd
  3. Jul 8, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    Hello nburo! :smile:

    (have a û for copy-and-pasting :wink:)

    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 û. :smile:)
  4. Jul 9, 2009 #3
    Hello tiny-tim! =)

    I prefer LaTeX =P

    First of all, thanks for answering.

    So would it look like this?

    [tex]\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}][/tex]


    [tex]\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}][/tex]

    And [tex]\dot{\theta} = \omega[/tex] only if [tex]\theta[/tex] isn't constant.

    So, if I'm not wrong, I am a bit confused. Since [tex]\omega[/tex] 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 [tex]\hat{u}(t)[/tex] 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 =(
  5. Jul 9, 2009 #4


    User Avatar
    Science Advisor
    Homework Helper

    Hello nburo! :smile:

    Why should ω be a vector? :confused:

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

    Does this come from a problem about a specific quaternion rotation? ​
  6. Jul 9, 2009 #5
    Well, when we have [tex]\hat{u}(t)[/tex] constant :

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

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

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

    [tex]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[/tex]

    where t is time, T is the final time, [tex]\phi[/tex] 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
  7. Jul 9, 2009 #6


    User Avatar
    Science Advisor
    Homework Helper

    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.
  8. Jul 9, 2009 #7
    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 :

    [tex]\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}) ][/tex]

    [tex] = \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)[/tex]

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

    How so?

    EDIT : Be right back in 2 hours : take your time my friend =)
  9. Jul 9, 2009 #8


    User Avatar
    Science Advisor
    Homework Helper

    erm :redface:your job, not mine!

    Try it and see! (I admit I haven't, but I think it'll work) :smile:
  10. Jul 9, 2009 #9
    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 =)
  11. Jul 9, 2009 #10


    User Avatar
    Science Advisor
    Homework Helper

    Yes, I assumed that! :rolleyes: :biggrin:

    btw, I forgot to ask … what's φ? … it seems to have come from nowhere. :confused:
  12. Jul 9, 2009 #11

    it's the angle between A and B! =)
  13. Jul 9, 2009 #12


    User Avatar
    Science Advisor
    Homework Helper

    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 :wink:
  14. Jul 9, 2009 #13


    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 :confused:

    Anyways, I also derived p(t) :

    [tex]\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[/tex]

    Because A and B are constant vectors.

    Also, in interpolation references, they use something like [tex]\tau = \frac{t}{T}[/tex] 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?
  15. Jul 9, 2009 #14


    User Avatar
    Science Advisor
    Homework Helper

    What's the k base? :confused:

    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.
  16. Jul 9, 2009 #15
    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?

  17. Jul 9, 2009 #16


    User Avatar
    Science Advisor
    Homework Helper

    Yup! :biggrin:
    Looks ok to me. :smile:
  18. Jul 9, 2009 #17
    You're one quaternion beast! :wink:

    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 [tex]q_\omega(t)[/tex] 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!
  19. Jul 9, 2009 #18


    User Avatar
    Science Advisor
    Homework Helper

    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 :smile:

    (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 || :wink:)
    Last edited by a moderator: Apr 24, 2017
  20. Jul 10, 2009 #19
    Re: David Baraff

    WHAT???? You know that? :biggrin: 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
  21. Jul 11, 2009 #20

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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

    [tex]\dot{Q} = \frac 1 2 \begin{bmatrix} 0 \\ {\boldsymbol{\omega}} \end{bmatrix} Q[/tex]

    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

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

    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{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

      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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook