Hi;
In python we have a function that returns the Rotation matrix for calculating the Transformation between axis orientations. Lets say i want to convert from Forward -Y orientation to Forward-X orientation. In python i would do this (copied from the python console and slightly edited for better reading):
from bpy_extras.io_utils import axis_conversion
global_transform = axis_conversion('Y', 'Z', 'X', 'Z')
The variable global_transform then contains:
Matrix(
( 0.0, 1.0, 0.0),
(-1.0, 0.0, 0.0),
( 0.0, 0.0, 1.0)
)
We have an equivalent function in C
float mrot[3][3];
mat3_from_axis_conversion(
BC_FW_Y, // = 0
BC_UP_Z, // = 2
BC_FW_X, // = 0
BC_UP_Z, // 2
mrot );
mrot then contains:
float[3][3](
( 0.0, 1.0, 0.0),
(-1.0, 0.0, 0.0),
( 0.0, 0.0, 1.0)
)
So far so well, but in the C universe i expect to get the transposed version of that matrix!
Why? Because i want to combine mrot with an object transformation matrix, for example to
mul_m4_m3m4(obmat, mrot, obmat);
When i do that with the result from mat3_from_axis_conversion() then i get the wrong rotation (180 degrees offset)
Some more digging shows that indeed the python function and the C function create the exact same result:
release/scripts/modules/bpy_extras/io_utils.py line 178 and following
source/blender/blenlib/intern/math_rotation.c line 2171 and following
If my finds are correct then i wonder if mat3_from_axis_conversion() shouldn’t better return the transposed matrix so to be compatible with how the Blender C-environment handles matrices ?
If the function won’t be changed (which is understandable) shouldn’t there be at least a comment that “it returns matrix data in Python orientation” ?