My reasoning for assuming this was a bug:
1. Previously working scripts (2.49) broke.
2. m1 *= m2 is equivalent to m1 = m1 * m2, where m1 represents the Base
matrix and m2 represents the Influencing matrix. This is more intuitive to
me.
There is no equivalent shorthand for m1 = m2 * m1.
e.g. Apply a series of transforms to produce a single transformation
matrix
contextMatrix = mathutils.Matrix()
for part in parts:
contextMatrix *= data.tran.matrix[part.matrix_index]
contextMatrix *=
data.tran.matrix[part.parent.matrix_index]
...
newObject.matrix_basis = contextMatrix
3. Treating leftMatrix as the Base and rightMatrix as the Influencing
facilitates a hypothetical method of varying argument counts.
e.g. resultMatrix = Matrix.Combine(baseMatrix, translateMatrix,
rotationMatrix, scaleMatrix, ...)
The above outlines my thought process. I was not aware that the change was
intentional. In light of the ... stop breaking APIs? discussion, we may
be better served by leaving it as-is.
Scott
-Original Message-
From: Campbell Barton [mailto:ideasma...@gmail.com]
Sent: Wednesday, July 20, 2011 2:16 AM
To: bf-blender developers
Subject: Re: [Bf-committers] Patches Submitted
On Wed, Jul 20, 2011 at 3:37 PM, Scott Giese scott.gi...@comcast.net
wrote:
Hi Gang,
FYI. I submitted 3 patches for your review. I'm new to the list and I
wanted to give back to the Blender community.
28030 SCONS Build: Build Date reflects
http://projects.blender.org/tracker/index.php?func=detailaid=28030group_i
d=9atid=127 1 instead of actual date of build
28031 Minor typo in Blenlib
http://projects.blender.org/tracker/index.php?func=detailaid=28031group_i
d=9atid=127
28032 Python Mathutils: Matrix Multiplication Error
http://projects.blender.org/tracker/index.php?func=detailaid=28032group_i
d=9atid=127
Great work guys! Appreciate the great product.
Scott
Thanks for the fixes, committed all patches however you're changes to
mathutils effectively only change the order of multiplication,
http://projects.blender.org/tracker/index.php?func=detailaid=28032group_id
=9atid=127
In you're example
print (m1 * m2)
Change to...
print (m2 * m1)
This is a bit confusing because in C we have
mul_m4_m4m4(m1, m2);
which is the equivalent to m2 * m1 in python.
A while back Benoit Bolsee was concerned our matrix multiplication
order was wrong so we switched it (between 2.4x and 2.5x)
What makes you think the order in blender is wrong? what's you're reference?
Just checked and we're currently doing matrix multiplication
differently to numpy which doesn't bode well :S - test:
# --- snip
m1 = ((0.0, 0.0, 1.0, 0.0), (-1.0, 0.0, 0.0, 0.0), (0.0, -1.0, 0.0,
0.0), (0.6, 0.0, -0.05, 1.0))
m2 = ((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0,
0.0), (0.0, -0.02, -0.1, 1.0))
from numpy import matrix
n_m1 = matrix(m1)
n_m2 = matrix(m2)
print(\nnumpy\n%r % (n_m1 * n_m2))
from mathutils import Matrix
b_m1 = Matrix(m1)
b_m2 = Matrix(m2)
print(\nmathutils\n%r % (b_m1 * b_m2))
# --- output
numpy
matrix([[ 0. , 0. , 1. , 0. ],
[-1. , 0. , 0. , 0. ],
[ 0. , -1. , 0. , 0. ],
[ 0.6 , -0.02, -0.15, 1. ]])
mathutils
Matrix((0.0, 0.0, 1.0, 0.0),
(-1.0, 0.0, 0.0, 0.0),
(0.0, -1.0, 0.0, 0.0),
(0.62, 0.1, -0.05, 1.0))
# --- switch m1/m2 order for both mathutils and numpy. re-run
numpy
matrix([[ 0. , 0. , 1. , 0. ],
[-1. , 0. , 0. , 0. ],
[ 0. , -1. , 0. , 0. ],
[ 0.62, 0.1 , -0.05, 1. ]])
mathutils
Matrix((0.0, 0.0, 1.0, 0.0),
(-1.0, 0.0, 0.0, 0.0),
(0.0, -1.0, 0.0, 0.0),
(0.6, -0.0, -0.15, 1.0))
___
Bf-committers mailing list
Bf-committers@blender.org
http://lists.blender.org/mailman/listinfo/bf-committers