 # Convert matrix to Orientation vector. Can i do it?

I don’t actually understand how can i convert matrix 3x3 to vector, using mathutils. I really need to get vector from one object to another, get absolute rotation vector of first object(Orientation), and get 3 axis angles between these two vectors. But worldOrientation returns matrix!

I know how to get 3 rotation angles x, y, and z between vectors, but i need vectors, not matrix!

This way you can get world-space vector of objects Z-axis:

``````import bpy
from mathutils import Vector
obj =  bpy.context.object
t_mat, rot_quat, sc_mat = obj.matrix_world.decompose()

# 2.79
z_vec = rot_quat.to_matrix().to_3x3() * Vector((0, 0, 1))

#2.8
#z_vec = rot_quat.to_matrix().to_3x3() @ Vector((0, 0, 1))

``````

And, maybe, can i convert matrix to vector?. I found an idea to get rotation, but i’m just interrested, how, if it’s posible, can i do that.

To improve a bit on yursiv’s answer, you don’t need the decomposition and quaternion multiplication steps. The columns of a transformation matrix represent the transformed x,y and z axes of the local object:

``````import bpy
from mathutils import Vector
obj =  bpy.context.object
z_vec = obj.matrix_world.col.to_3d() # index 0 would be x axis, 1 would be y axis and 2 is the z axis
``````

However I would have some questions back to _IcEbERg:
What do you exactly mean by the vector you want to convert to? Is it the vector of Euler angles? Would you consider a quaternion a vector? A vector, you want to transform from one object to another? If so, which kind of vector (a vector to a point in space, a vector representing a direction or a normal)?