# How to control the direction a bone rotates?

I rotated the upper arm bone of my armature approximately 180° by hand (with R and the mouse), but it goes around the wrong way:

I tried going to the problem keyframe, rotating the bone ~-360° (i.e. the opposite direction it rotates in the gif above, but so it's roughly in the same position), however this didn't seem to help.

How is the rotation direction defined in such cases? How can I control it predictably?

• I think shortest path plays a part, one or two degrees can make it go the other way. I think the easiest solution is to add a middle keyframe, key start, key half way in front, then final pos. To fix after would be to change the curves in the graph editor. Care to share? Jan 22, 2015 at 9:08
• @sambler I actually just tried deleting the keyframes and re-animating, being absolutely sure I rotated it around the right direction after pressing R. I'm not sure if that's what did it, but it worked. Unfortunately I only now realized I don't have a backup with the old keyframes, but I could make a fresh test file if you want. Jan 22, 2015 at 9:16
• If you have a working copy make a backup, and if you can re-create the error then compare the curves in the graph editor and see how one rotates different to the other. Jan 22, 2015 at 10:21
• I guess if you use quaternions you could just invert all components signs of one keyframe to get the opposite rotation. But a full 360 degree rotation might still need intermediate steps. Jan 22, 2015 at 12:51

Experiencing this kind of rotation interpolation problems are not common in your case because you are using Quaternion Rotation. But similar problems can be found easily in the shoulder-like joints if you are using Gimbal rotation (any of the Euler XYZ combinations). Anyway, there is a similar approach for both cases.

First, you need to know what kind of rotation is being used. It's simple: under rotation axes you'll find Quaternion or Euler (in this case means Gimbal).

The common solution for both rotation types is adding one (or many) inbetween keyframe to "force" the rotation to go through your desired way (like @sambler told in the comments). If you are working with Quaternions, doing that is a must in big rotation changes.

Why does it happen? In Quaternion, the WXYZ axis are defining a point in a 4-dimensional sphere. For better understanding, we can imaging the same applied to a circle in this image:

So the rotation is actually a point traveling through a circle but not only through the edge. In your case, I think that your rotation was more than 180 degrees, so the interpolation went by "the other way" of the circle.

Note that the spacing of the rotation is not linear, so it's always recommended inserting inbetween keyframes specially in big rotations.

In Gimbal that's caused because of the gimbal lock. Gimbal axes are parented between themselves. So if you're working on a Euler XYZ setup, X is the child of Y, which is the child of Z. If you rotate 90 degrees the Y axis, then the X axis will align with the Z resulting that two axes are doing the same rotation and you have lost a rotation axis actually.

So there's another solution if you are working with Gimbal: Euler Filter. Euler Filter is located in the F-Curve Window in the Key Menu:

There is plenty of material in the Internet about Gimbal lock. If you want to know more about Quaternions or Gimbal in Blender, are pretty well covered in Nathan Vegdahl's Humane Rigging DVD (you can check Quaternions video here). Actually the two circle images are from that video (under a CC Licence).