[Papervision3D] matrix multiplication order
Tim Knip
tim.knip at gmail.com
Sun May 10 06:51:21 PDT 2009
Hi,
That's correct.
pre-multiplying with the object's transform, is same as
post-multiplying with the object's inverse transform.
(or vice versa, always forget)
Why? urgh: there's a math-reason for it :-)
Say you walk the scenegraph:
post-multiplying each child with its parent's transform : stuff all
ends up in object space
pre-multiplying each with its parent's transform : stuff all ends up
in world space
Note: the above is just a crude explanation! :-)
Tim
2009/5/9 grizu <grizuuu at gmx.at>:
> I did a little experiment.
> I have a vector in global space, which I want to rotate my object about. I
> multiplied this vector with my objects inverse matrix to get it into object
> space. Then I rotated my object about it with:
> do3d.transform.calculateMultiply (do3d.transform, rotationMatrix)
> And it works as it should! :)
>
> So, why if I rotate my object with flipped params:
> do3d.transform.calculateMultiply (rotationMatrix, do3d.transform)
> I get the same (right) effect, without doing the inverse thing. What happens
> here?
>
> Would be very nice if someone could shed some light on this.
> Thanks a lot,
> Chris
>>
>> Thank you Andy, what you said is clear to me. But I only have one
>> RotationMatrix...
>> Just thinking, why does
>> do3d.transform.calculateMultiply (m1, m2)
>> take two parameters? I only have one rotationmatrix, and simply want to
>> transform my object with it.
>>
>> If I have
>> do3d.transform.calculateMultiply (do3d.transform, rotationMatrix),
>> I multiply my object's matrix with the rotationmatrix (at least I thought
>> so). Or is it object*matrix*object?
>>
>> What happens if I flip the parameters? I multiply matrix*object, then with
>> my object?.... *confused*
>>
>> Thanks!
>> Chris
>>>
>>> The order is important since matrix multiplication isn't commutative.
>>> (Consider the differences of multiply row->colum and how its different
>>> depending on which matrix is first). Essentially, the matrix in the first
>>> position is applied "first". Think if you want to apply a rotation and
>>> translation on an object. If you do translate*rotation, your object will be
>>> "moved", then rotated, meaning your object will rotate around the translated
>>> center rather than its original origin. If you do rotate*translate, you
>>> would rotate around its center, then move out from there.
>>>
>>> consider code (not sure if this is correct, but you can fix the syntax if
>>> not:)
>>>
>>> sphere.transform.calculateMultiply4x4(Matrix3D.rotationMatrix(0, 1, 0,
>>> Math.PI/2), Matrix3D.translationMatrix(300, 0, 0));
>>>
>>> This code will rotate the sphere (around origin of scene) 90 degrees and
>>> move it down its new X axis (which is now the Z axis in world space)
>>>
>>> If you flip those two params, it will move out to the right, and then
>>> rotate around its new center.
>>>
>>> hopefully that will help somewhat - a more thorough explanation might be
>>> needed.
>>>
>>> -andy
>>>
>>>
>>>
>>>
>>> On May 8, 2009, at 9:24 AM, grizu wrote:
>>>
>>>>
>>>> Hello!
>>>>
>>>> Could someone tell me, what is the difference between:
>>>>
>>>> do3d.transform.calculateMultiply3x3 (do3d.transform, rotationMatrix);
>>>>
>>>> and
>>>>
>>>> do3d.transform.calculateMultiply3x3 (rotationMatrix, do3d.transform);
>>>>
>>>> I know that order is important, when multiplying matrices (rotX, rotY,
>>>> rotZ,
>>>> then translation, is this right?). But I can't understand, what is going
>>>> on
>>>> here. I tried the first thing, which seems logic to me: I simply
>>>> multiply an
>>>> object's transform with a rotation matrix. But my simple scene only
>>>> works
>>>> with the second way.
>>>> It would be very nice, if someone could explain this to me. I try to get
>>>> into this matrix-thing, but it is not easy sometimes...
>>>>
>>>> Thanks in advance!
>>>> Chris
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/matrix-multiplication-order-tp23446997p23446997.html
>>>> Sent from the Papervision3D mailing list archive at Nabble.com.
>>>>
>>>>
>>>> _______________________________________________
>>>> Papervision3D mailing list
>>>> Papervision3D at osflash.org <mailto:Papervision3D at osflash.org>
>>>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Papervision3D mailing list
>>> Papervision3D at osflash.org
>>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>
>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
More information about the Papervision3D
mailing list