You can’t change the blender matrix, it is read only, if that is what you wanted to do. But in any case here is a some code from what is used in Dynamica, this gets you 3x3 rotation matrix for the specified axis:

```
# creates rotation matrix around X, Y or Z
# axis must be 'X', 'Y' or anything else=='Z'
# angle in radians, all made equivalent to blenders matrices from RotXYZ
def makeRotMtx(axis, angle):
if axis=='X':
rs, rc = sin(angle), cos(angle)
mtx = [ [1.0, 0.0, 0.0],
[0.0, rc, rs],
[0.0, -rs, rc] ]
elif axis=='Y':
rs, rc = sin(angle), cos(angle)
mtx = [ [ rc, 0.0, -rs],
[0.0, 1.0, 0.0],
[ rs, 0.0, rc] ]
else:
rs, rc = sin(angle), cos(angle)
mtx = [ [ rc, rs, 0.0],
[-rs, rc, 0.0],
[0.0, 0.0, 1.0] ]
return mtx
```

If you want to rotate all three in one go, you could use the above function to create 3 matrices and multiply them, but instead it is much faster to use this optimized function:

```
# creates full 3D rotation matrix
# rx, ry, rz angles in radians
def makeRotMtx3D(rx, ry, rz):
A, B = sin(rx), cos(rx)
C, D = sin(ry), cos(ry)
E, F = sin(rz), cos(rz)
AC, BC = A*C, B*C
return [[D*F, D*E, -C],
[AC*F-B*E, AC*E+B*F, A*D],
[BC*F+A*E, BC*E-A*F, B*D]]
```

But like I said, all these are no use if you want to change the Blender matrix, that can’t be done. Although you could use it in GameBlender with setOrientation maybe, but I’m not sure if you actually get the correct orientation. I changed everything so I would get consistent results with what Blender’s matrices would return when changing RotX/Y/Z. I don’t know if the game engine is different.