1
$\begingroup$

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!).

$\endgroup$
0
$\begingroup$

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:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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