PDA

View Full Version : Matrix3 Help?

 sumchans04-04-2012, 09:34 PMI created a box exactly on the center of the viewport and then i was trying some script operations on the box especially the matrix3 constructor. After creating the box i ran these codes on the listener 1. b.transform I got : (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]) 2. temp= b.transform temp.row3 = [0,1,1] b.transform = temp i got: (matrix3 [1,0,0] [0,1,0] [0,1,1] [0,0,0]) 3. And finally i tried b.transform.scalepart i got: [1,0.618034,1.61803] My question is wht does these values returned from the last code say. A detailed explanation will be very well appreciated. Thanks all for the contd support.
Bobo
04-04-2012, 10:21 PM
First of all, you have to understand what the matrix3 value represents.
The row1,2 and 3 represent the 3 axes of the transformation matrix. Their orientations represent the orientation (rotation) of the object relatively to the world, and their length represents the scale along each axis. The row4 is the translation from the world origin.

In other words, entering temp.row3 = [0,0,2] would apply 200% scale along the Z axis,
entering temp.row4 = [100,100,0] will offset the object along X and Y by 100 units each.

Normally, the 3 axes are supposed to be ORTHOGONAL to each-other. But when you entered [0,1,1] for row3, you broke that and got NON-UNIFORM scaling where the Z axis is skewed and is not perpendicular to the other two axes anymore. That's why asking for the scale part shows a non-uniform scaling along the Y and Z - the length of [0,1,1] is not 1.0, so you are introducing some scaling along both Y and Z, and skewing the Z axis at 45 degrees about X.

When you want to rotate an axis, you should also make sure the other axes also rotate to preserve the right angles between the 3 axes. For example, you could multiply the transform by a rotation matrix, like 45 degrees about X while keeping all axes orthogonal:
b.transform *= rotateXMatrix -45

MAXScript also provides a function to orthogonalize a matrix to restore the right angles:
b.transform = (orthogonalize b.transform)

I am not sure what you expect to do with these values, but this is the explanation of WHY you got what you got...

sumchans
04-05-2012, 12:55 AM
Oh wow, thanks Bobo never expected a reply from you.

I am just planning on getting deep into this section. I already done a lot of study on this, but still at times i get all these things totally confused. Getting into particle flow projects, i understand that the knowledge of the whole matrix concept would help create some nice effects.

By the way your explanation was detailed,

thanks Bobo again.

CGTalk Moderation
04-05-2012, 12:55 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.