Vertex Rotation / RotationMatrix

I think this is a stupid question but anyways, I’m trying to modify my exporter to transform the mesh vertices so that the “front view” in Blender matches my game’s default camera position. So I’m trying to apply some rotations to the vertices of the exported mesh.

My question is - I don’t understand how the code below is working, I’m trying to rotate a single vertex (0,1,0) about the X-axis +90 degrees, which I thought would put the vertex at (0, 0, 1) ? But the result I get below is different.

>>> from mathutils import Vector, Matrix, RotationMatrix
>>> mat_rotation = RotationMatrix(90, 4, 'X')
>>> vec0 = Vector([0, 1, 0])
>>> vec1 = vec0 * mat_rotation
>>> vec1
Vector((0.0, -0.4480695128440857, -0.8939987421035767))

I guess I’m confused because when I pick that same point on a simple cube mesh, and rotate the cube +90 along global X axis, the point ends up at (0,0,1) like I would expect.


There’s an error in the docs. The angle parameter is in radians, not degrees.

from math import *
from mathutils import RotationMatrix, Matrix, Vector
mat_rotation = RotationMatrix(radians(90), 4, "X")