Hi, I repeat once more: mathutils matrices are COLUMN-MAJOR. This means that the top elements in the definition list are columns, not rows, despite the fact that they are printed horizontaly. So the following code:
m1 = Matrix([[ 1, 0, 2], [-1, 3, 1]]) m2 = Matrix([[3, 1],[2, 1],[1, 0]]) print(m1*m2) Translates into this in ordinary notation: (1 -1) X (3 2 1) = (2 1 1) (0 3) (1 1 0) (3 3 0) (2 1) (7 5 2) Which is exactly what blender returns. Mathutils matrices are column-major because that's how Blender stores the matrices internal, and Blender uses that convention because openGL uses it. > -----Original Message----- > From: bf-committers-boun...@blender.org > [mailto:bf-committers-boun...@blender.org] On Behalf Of > bf-committers-requ...@blender.org > Sent: mercredi 27 juillet 2011 12:00 > To: bf-committers@blender.org > Subject: Bf-committers Digest, Vol 84, Issue 26 On Tue, 26 Jul 2011 16:49:54 +0200, "Peter K.H. Gragert" <pkhgrag...@gmail.com> wrote: > > 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 > _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers