On 03/02/2013 at 14:43, xxxxxxxx wrote:
i am trying to import some tracking data (faceshift) into c4d.
everything works fine, except that i can not get the head-rotation work properly.
the head rotation i get from faceshift is in quaternion format and consist of 4 float values (x,y,z,w)
i tried doing something like this:
i tried a lot with swapping or negating the values x,y,z and w, but had no luck so far.
i know that faceshift and c4d do not use the same coordinates systems (left handed vs right handed), because to get the head-translation correctly i need to negate the z-value.
hope someone can show me the way....
On 03/02/2013 at 15:55, xxxxxxxx wrote:
OK I solved it myself:
Here is how i got it working:
newMatrix = quaternionToMatrix(x,y,z,w)
def quaternionToMatrix(x,y,z,w) :
xx = x * x;
xy = x * y;
xz = x * z;
xw = x * w;
yy = y * y;
yz = y * z;
yw = y * w;
zz = z * z;
zw = z * w;
vec1.x = 1 - 2 * ( yy + zz );
vec1.y = 2 * ( xy - zw );
vec1.z = 2 * ( xz + yw );
vec2.x = 2 * ( xy + zw );
vec2.y = 1 - 2 * ( xx + zz );
vec2.z = 2 * ( yz - xw );
vec3.x = 2 * ( xz - yw );
vec3.y = 2 * ( yz + xw );
vec3.z = 1 - 2 * ( xx + yy );
here is the link where i found the function: