[Bf-committers] matrix multiplication in Blender SVN of this morning (W32 Vista mingw compiled)

Peter K.H. Gragert pkhgragert at gmail.com
Tue Jul 26 16:49:54 CEST 2011


Hallo,
First try ...

Put this text in the console and run it
============code start=============
import bpy
from mathutils import Matrix
print("\n----START---")
m1 = Matrix([[ 1,  0,  2],
        [-1,  3,  1]])
print(m1, "\nelement R(2,3)")

m2 = Matrix([[3, 1],
        [2, 1],
        [1, 0]])
print(m2, "\nelement R(3,2)")

print("m1 * m2 =", m1*m2, " should be element R(2,3) * R(3,2) => R(2,2) but
is R(3,3) so math it looks like m2 * m1 so it is STRANGE!")

print("m2*m1 = ", m2*m1, " should be element R(3,2) * R( 2,3) => R(3,3) but
is R(2,2) so math it looks like m1 * m2,(consistantly) STRANGE")

# checking what *= means
m1_Copy = m1.copy()
m1_Copy *= m2
m1_BlStar_m2 = m1_Copy
print("m1 BLender *= m2",  m1_BlStar_m2 ,"should be element dependant of
what *= means , right or left multiplication")
print("result shows it is interpretated as math: m1 * m2, \n\n ==> so  math
RIGHT  multiplication!")
print( "check:",   m1 * m2 == m1_BlStar_m2 )
print("\n+++++++++++++ now again?!!??? ")
m1_BlStarm_m2_Copy = m1_BlStar_m2.copy()
m1_BlStarm_m2_Copy *= m2
m1_BlStar_m2_BlStar_m2 = m1_BlStarm_m2_Copy
print(" m1 BlStar_m2_BlStar_m2 =\n", m1_BlStar_m2_BlStar_m2, "\nshould be
ERROR R(3,3) * R(3,2) => R(3,2) but is R(3,3) ERROR!")

============code end=============


==>   matrix multiplication is NOT like math matrix multiblication

m1 * m2 in Blender correspondent with m2 * m1 in math (STRANGE not nice ....
but ... let it be so)

But THEN  *=
m2  *=  m1 behaves very strange and to my opinion wrong!

Greetings
   Peter K.H. Gragert


More information about the Bf-committers mailing list