Exporting bones; transformation of quaternions necessary? I'm writing a small addon to export armatures and actions to an in-house rendering engine. The rendering engine uses a traditional OpenGL-style coordinate system, with +Y representing UP and -Z representing FORWARD.

Bones in the in-house system store a location, rotation (quaternion), and scale, so I'm exporting to this representation directly. In the addon, I'm using Blender's standard axis conversion functions to transform positions to the target coordinate system. However, my mathematical understanding of quaternions is somewhat weak and I'm not entirely sure if I need to be transforming quaternions too.

While I understand that quaternions do not have "handedness" or anything like that, I do feel that, for example, a quaternion that represents a rotation around the Z axis in Blender probably needs to be transformed so that it represents a rotation around the +Y axis in the target engine. Does this seem correct?

If some sort of transformation does need to occur, is there anything already in the standard API to facilitate this? I'm unable to find anything (possibly because it's not there, possibly because the transformation isn't actually necessary!).
The answer is yes: The quaternions do need to be transformed. If a quaternion represents a rotation around an axis in the source coordinate space, then it's inevitably not going to represent a rotation around the "same" axis in the target coordinate space if it isn't transformed.

As to how to do this in Blender:


Convert the quaternion to an axis/angle representation using the built-in API functions.
Transform the axis using the standard axis conversion functions that are supplied for vectors.
Convert the transformed axis/angle back to a quaternion using the built-in API functions.