Camera animation doesn't rotate along shortest path I'm new to Blender, and I'd like to animate my camera rotating around 360 degrees to show off part of a 3d model. I have a setup, and the camera will move, but instead of pivoting all the way around the camera will rotate most of the way, and then spin all the way (more than 180 degrees) back around. Here's an example



And here's the code:

camera.keyframe_insert(data_path="rotation_euler", frame=0.0, index=-1)
camera.rotation_euler.rotate_axis( 'Y', 2 * math.pi / 3 )
camera.keyframe_insert(data_path="rotation_euler", frame=frames/3., index=-1)
camera.rotation_euler.rotate_axis( 'Y', 2 * math.pi / 3 )
camera.keyframe_insert(data_path="rotation_euler", frame=2.*frames/3., index=-1)
camera.rotation_euler.rotate_axis( 'Y', 2 * math.pi / 3 )
camera.keyframe_insert(data_path="rotation_euler", frame=frames, index=-1)


Is there a good solution to this?
Instead of rotating around a global axis with rotate_axis set absolute values to the rotation channels and handle all the relative transformations in code.

camera.rotation_euler = (math.pi/2, 0, 0)
camera.keyframe_insert(data_path="rotation_euler", frame=0.0)

prevRot = camera.rotation_euler
nextRot = (prevRot[0], prevRot[1], prevRot[2] + 2 * math.pi)
# or absolute values
# nextRot = (math.pi/2, 0, 2*math.pi)

camera.rotation_euler = nextRot
camera.keyframe_insert(data_path="rotation_euler", frame=frames)


The script presumes Y is Up.