[Bf-python] 3DVec * 4x4Matrix issue

Campbell Barton cbarton at metavr.com
Sat Jul 22 05:18:47 CEST 2006


Hi, This was mentioned a while ago, but I dont think any conclusion was 
reached..

A problem I come across almost weekly from new scripters is how to get 
the worldspace location of a vector from object data, a vert say 
(through emails end blenderartist python forum)

world_vec= vec*matrix works if the vector  4D but for 3D vectors it 
dosent apply the translation.

Solutions are ...

mtx= ob.matrixWorld
vec_copy= Mathutils.Vector(vec)
vec_copy.resize4D()
vec=vec_copy*mtx
vec.resize3D()
or...

mtx= ob.matrixWorld
vec=vec*mtx
vec= vec+mtx.translationPart()
or..

do the matrix multiplication manually..

Could we just have the matrix multiplication apply transformation to a 
3D vector?

- Cam




More information about the Bf-python mailing list