1
$\begingroup$

I have a skeleton (in asf/amc format), from CMU's mocap database. I'm using python, no libraries yet. (Blender in python mode doesn't work properly for this, as far as I know.)

I want to mirror the movement, swapping sides, assigning the right arm movement to the left arm and so on.

The number of degrees of freedom for each joint is between 1 and 3. Angles are stored in euler format, XYZ. All angles are local, relative to the parent bone.

Quite obviously, just renaming the objects (rhand<->lhand) doesn't work. Where do I start?

$\endgroup$

1 Answer 1

3
$\begingroup$

Mapping the Left and Right Sides

This step should be trivial. If I remember correctly, the CMU database animation skeletons have easily identifiable bone names. If not, then it's slightly less trivial. What you would have to do then would be to start at the root and go down each side. The bone structure should be the same for each animation though.

Create the Rotation Matrix

You should have three Euler angles: $X$, $Y$, and $Z$. You first need to create a rotation matrix for each bone. I use $\phi$ for $X$, $\theta$ for $Y$, and $\psi$ for $Z$ since this is a more common notation for matrix $R$. This is a right-handed matrix.

$$ \begin{bmatrix} \cos(\theta)\cos(\psi) & \cos(\phi)\sin(\psi) + \sin(\phi)\sin(\theta)\cos(\psi) & \sin(\phi)\sin(\psi) - \cos(\phi)\sin(\theta)\cos(\psi) \\ - \cos(\theta)\sin(\psi) & \cos(\phi)\cos(\psi) - \sin(\phi)\sin(\theta)\sin(\psi) & \sin(\phi)\cos(\psi) + \cos(\phi)\sin(\theta)\sin(\psi) \\ \sin(\theta) & - \sin(\phi)\cos(\theta) & \cos(\phi)\cos(\theta) \end{bmatrix} $$

Flip the Sides

To flip the rotation matrix, you will need to multiply the axis you want to flip by $-1$. This is equivalent to scaling in across that axis. I will assume you want to scale across the x-axis for matrix $S$.

$$ \begin{bmatrix} -1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} $$

Combine the Two Transforms

Now just multiply these two matrices, and you get the opposite rotation: $$T = R \times S$$

Chain Together the Local Transforms

Now you just need to apply forward kinematics, so you need to multiply each parent matrix by the local matrix to get an absolute transformation matrix.

$\endgroup$
2
  • 1
    $\begingroup$ Is the dot notation correct or even common for matrix multiplication? I've only seen it as a cross ($A \times B$) or omitted ($AB$). $\endgroup$ Commented Oct 3, 2016 at 2:42
  • $\begingroup$ Oops, yeah I think you're right. I just get used to using dots for multiplication. :) $\endgroup$
    – aces
    Commented Oct 3, 2016 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.