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$
2
  • $\begingroup$ Is your plane at the origin (0,0,0)? $\endgroup$
    – David
    May 30, 2015 at 13:36
  • $\begingroup$ yes , it is @David $\endgroup$ May 30, 2015 at 13:41

1 Answer 1

7
$\begingroup$

to multiply Matrix with Vector, order is important:

v2 = matrix * vector

see: mathutils.html#mathutils.Vector

$\endgroup$
2
  • $\begingroup$ that was it, thanks. I don't know why they don't make that a little more apparent though. $\endgroup$ May 30, 2015 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, 2015 at 20:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .