# How to flip an animation in Quaternion?

I have an animation of a walking avatar using mocap. He walks and turns left. I want to change it to turn right. The rotation system of pose bones is Quaternion. How to make it?

The left bone and the right bone can be flipped, but the root bone can't be. Are there any ways to mirror across axis in 3Dview? I only found the mirror in the graph editor, which can't help.

Or should I change Quaternion to Euler for the flipping and change Euler back to Quaternion???

1. Make a copy of your rig and remove the animation (unlink the action on the duplicate).

2. Flip your original rig by going into Object mode and setting scale in X-axis to -1.0 on the object.

3. Add a Copy Rotation constraint for each bone of the duplicate rig that will target the opposite bone in the original rig - ie. Arm.L will copy rotation from Arm.R:

Set the constraints in Local space, check inverse for Y and Z axis:

Automate it with python:

import bpy
orig = bpy.data.objects["NAME_OF_ORIG_RIG"]
copy = bpy.data.objects["NAME_OF_COPY_RIG"]

for pb in copy.pose.bones:
const = pb.constraints.new("COPY_ROTATION")
const.target = orig
const.subtarget = pb.name.replace(".L","§").replace('.R','.L').replace('§','.R')
const.invert_y = True
const.invert_z = True
const.target_space = const.owner_space = 'LOCAL'

4. Bake the animation on the copy rig into an action:

Pose > Animation > Bake Action > set settings:

5. Flip your original rig back by setting X-scale to 1.0

6. Switch the original mocap action with the baked action.

7. Delete the rig copy.

8. Optionally automate it all in python.

This approach shows how and why it works and is understandable for someone not familiar with quaternion math or python. You can also achieve the same by transforming F-curve channels directly with python by using that quaternion rotation math.

• What about math method? Change qua to one of eul, make a rotation, change eul back to qua? Or use the math formula to calculate? Dec 6 '18 at 4:30
• I scale the original rig in X-axis to -1. The avatar is somehow in a mess.... I followed the steps and it doesn't work... Dec 6 '18 at 4:48
• @萌香ちゃん Maybe your rig setup is more complicated than an armature with mocap action? Can you share your .blend file or some pictures of how the rig works? Dec 6 '18 at 10:22
• link I use the avatar created from makehuman Dec 6 '18 at 13:46