How to rotate a vector?

Hi, everyone out there.

I was starting to play around with the game engine (Blender 2.63) and stumbled into a problem not beeing able to rotate Vector.
While the Api says there is a function in the vector class which takes two arguments : rotate(axis,angle),
the Compiler on the other Hand sayed he wanted only one argument in Form of a rotationmatrix.
Ok, i thougth. Lets do that so i created that Matrix by

rot_mat = mathutils.Matrix.Rotation( angle, 3, mathutils.Vector( (0, 0, 1) ) )

and tried to rotate the Vector with it

rotated_vector = vector_to_rotate.rotate( rot_mat )

But after that rotated_vector is None.

I searched quite while to found a solution, without success.

I would be glad, if someone gives me hint how to do that.

excuse, me for my poor english skills

You can rotate a vector with an Euler, Quaternion, or a Matrix. The results of doing the rotation are applied to the object itself. Try this in the python console.


>>> mat = Matrix.Rotation(math.pi / 2, 4, "Z")
>>> vec = Vector( (1, 0, 0) )
>>> vec.rotate(mat)
>>> vec

Note that the angle is specified in radians. “pi/2” is 90 degrees.

Fine, thanks a alot. That did the job.
I was a bit lazy yesterday while reading the API and didnt recognized the type of the axis given in Matrix.Rotation
But in case of the vector the Api did not seem to be correct or is has the behaviour of vector changed in 2.64?
Anyway i now can rotate my vectors.