# How do I extract a translation vector from a dual quaternion?

I'm trying to do some things with rigid body dynamics using dual quaternions (these are not the same thing as normal quaternions!) and I'm so close to getting things to work. The problem I'm having is extracting the translation vector from a dual quaternion. After looking some things up I found that if I have an array representing a dual quaternion like this one:

    JOINT[0,0]
JOINT[0,1]
JOINT[0,2]
...
JOINT[0,7]


Then the translation vector part is given by 2*(dual)'real where (dual)' is the conjugate quaternion of the dual part of the dual quaternion. This is what it looks like all typed out:

   x = 2*(-JOINT[0,4]*JOINT[0,1] + JOINT[0,5]*JOINT[0,0] - JOINT[0,6]*JOINT[0,3] + JOINT[0,7]*JOINT[0,2]);
y = 2*(-JOINT[0,4]*JOINT[0,2] + JOINT[0,5]*JOINT[0,3] + JOINT[0,6]*JOINT[0,0] - JOINT[0,7]*JOINT[0,1]);
z = 2*(-JOINT[0,4]*JOINT[0,3] - JOINT[0,5]*JOINT[0,2] + JOINT[0,6]*JOINT[0,1] + JOINT[0,7]*JOINT[0,0]);


However this isn't quite right. If I have an object not located at the origin it will rotate fine on the x and z axes but will freak out if I try to rotate it on the y axis. And if I rotate an object and then move it it will not move correctly. Anyways after a bunch of trouble shooting I'm pretty sure I am not extracting the translation portion of the dual quaternion correctly so I was hoping someone could tell me what I'm doing wrong.

@Christian Rau Thanks. You're right it was 2*d*r'. I don't suppose that you also know how to combine dual quaternions do you? I've tried multiplying two together (using the convention Q1*Q2 = r1*r1 + e(r1*d2 + r2*d1) where r is the real part and d is the dual part). I should probably explain that what I'm trying to do is combine a dual quaternion that describes and object's current position and orientation with one that describes it's change in position and orientation in order to find a dual quaternion that describes it's position and orientation after the change. However right now I can't get it to come up with the correct translation after multiplying the two together (I've tried both orders, Q1*Q2 and Q2*Q1).

@Christian Rau I meant to say Q1*Q2 = r1*r1 + e(r1*d2 + d1*r2) which is how I've been multiplying them together so far. The object that I'm displacing is sort of behaving correctly. It rotates relative to its own center of mass but as it rotates the axis of rotation changes. For instance if I rotate it on its z axis its x and y axes will rotate with it. I can get it to move only relative to its own axes. So it will move along its x axis If I want it to but if its x axis is no longer parallel to the global x axis it isn't doing much for me.

According to this paper about dual quaternion skinning, the translation vector corresponding to a unit dual quaternion is extracted as 2*dual*(real)' rather than your 2*(dual)'*real. I can confirm this after applying dual quaternion skinning in practice.

Now there may be different dual quaternion conventions (not sure about that), but it is worth a try. So just try to switch the quaternion conjugation from dual to real.

EDIT: You also seem to have an error in your dual quaternion multiplication code. You write that Q1*Q2 = r1*r2 + e(r1*d2 + r2*d1), but this is wrong, since quaternion multiplication is non commutative and when multiplying Q1 and Q2, the 1-parts always have to be on the left and the 2-parts on the right. So it should actually be

Q1*Q2 = r1*r2 + e(r1*d2 + d1*r2)        (the last product has switched)


This makes no difference when working with simple dual numbers, but it matters the moment the individual elements (quaternions in this case) don't commute.

And by the way, since the dual quaternion transformation is theoretically applied to a point v as QvQ'*, two quaternions Q1 and Q2 should be multiplied in the order Q2 * Q1 to get a transformation that first transforms by Q1 and then by Q2.

For a noobs intro with source code on getting started with dual-quaternions, I'd take a look at this paper:

A Beginners Guide to Dual-Quaternions : What They Are, How They Work, and How to Use Them for 3D Character Hierarchies

• It's considered best if you actually post at least the basic intro here. Sep 30, 2012 at 15:52