5
$\begingroup$

I have a plane which I rotated up 90 degrees on X and 45 degrees on Z. I run this code to get the vertices world location's:

import bpy

ob = bpy.context.object
verts = [i.co * ob.matrix_world for i in ob.data.vertices]
print(verts)

The results I should get should be something like:

-0.707, -0.707, -1
0.707, 0.707, -1
-0.707, -0.707, 1
0.707, 0.707, 1

Instead I get:

-1.41, 7.1e-15, -1.19e-7
-1.19e-7, -1.06e-7, 1.41
1.19e-7, 1.06e-7, -1.41
1.41, -4.1e-15, 1.19e-7

What is going on here?

$\endgroup$
  • $\begingroup$ Is your plane at the origin (0,0,0)? $\endgroup$ – David May 30 '15 at 13:36
  • $\begingroup$ yes , it is @David $\endgroup$ – BlendingJake May 30 '15 at 13:41
7
$\begingroup$

to multiply Matrix with Vector, order is important:

v2 = matrix * vector

see: mathutils.html#mathutils.Vector

$\endgroup$
  • $\begingroup$ that was it, thanks. I don't know why they don't make that a little more apparent though. $\endgroup$ – BlendingJake May 30 '15 at 13:55
  • $\begingroup$ for a brief period in 2.5 series vector * matrix was valid, but it was changed to the algebraically more conventional matrix indexing, which made it m*v in 2.62 ( blenderartists.org/forum/… ) $\endgroup$ – zeffii May 30 '15 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.