I need to refine my understanding of matrix operations in Blender, specifically verion 2.8
This following code does a number of object manipulations
import bpy
import mathutils
import math
bpy.data.objects.remove(bpy.data.objects['Cube'])
bpy.ops.mesh.primitive_monkey_add(size=2, enter_editmode=False, location=(0, 0, 0))
# create a location matrix
mat_loc = mathutils.Matrix.Translation((5.0, 0.0, 0.0))
# create a rotation matrix
mat_rot = mathutils.Matrix.Rotation(math.radians(45.0), 4, 'Z')
mat_rot2 = mathutils.Matrix.Rotation(math.radians(-45.0), 4, 'X')
# initiallay Suzanne and world coordinate system are identical.
suz.matrix_world = suz.matrix_world @ mat_loc
# this rotates around global z-axis
suz.matrix_world = mat_rot @ suz.matrix_world
# this rotates around local x-axis
suz.matrix_world = suz.matrix_world @ mat_rot2
In the last two operations, the suz object is rotated. Why does the axis of rotation change from local to global depending on matrix_world being first or last in the matrix multiplication?