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.