# Matrix from quaternion produces a different orientation

I want to convert a quaternion to a matrix and back again. The result has a different orientation than the quaternion from the beginning.

To reproduce the problem, set a quaternion.

ob = bpy.context.object
bpy.context.object.rotation_quaternion = mathutils.Quaternion((0.7795193195343018, 0.045188724994659424, 0.15823090076446533, 0.048953697085380554))


Then convert the quaternion to a matrix and apply it back to the object.

ob.matrix_world = ob.rotation_quaternion.to_matrix().to_4x4()


The object not only changes its orientation, but its scale.

ob.matrix_world = ob.rotation_quaternion.normalized().to_matrix().to_4x4()