Notifications
Clear all

[Closed] about matrix3 ,help

sorry for i dont know how to use matrix3 in script , the help document in maxscripts help is a little hard for me to understand . mybe because i m a chinese .
is there any body show me some examples or teach me the detail about matrix3 . i know it is powerful in rotate objects and more ,but i cant use it freely like other value .

best rgds .

thanks for any reply !

14 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

It probably has nothing to do with your origin, the question is do you know math well?
It is a large subject, and I am recording a DVD entitled “The Matrix : Explained” as we speak.

In general, a matrix3 value represents a 4×4 transformation matrix. Every node and some object space modifiers use a matrix3 value to store their transformations and you are right that you can use matrices for rotations, alignment of objects and more.
In addition, matrix3 values can be used to transform one coordinate system into another, like world into object and back, transform world coordinates into view coordinates and so on.

The simplest thing to know is that assigning the .transform value of one node to the .transform of another node effectively aligns the one to the other:

For example,
$Box01.transform = $Sphere01.transform

causes the box to get aligned to the shpere.

The MAXScript Help assumes you already know enough mathematics to use matrices and only gives you the functions to use them.
Still, the Frequently Asked Questions chapter in the Help provides a couple of examples, like:
*How do I keep a Plane aligned to 3 Point Helpers?
*How do I rotate a vector around the Z axis?

Hope these will help you a bit…

Cheers,
Bobo

learn some now . have to back to learn more about matrix . thanks .

Hi all,

I myself am begining to dig into the transform matrix procedures and concepts, but as Bobo says, its more about math and matrix procedures than it is about programing or even 3D general knowledge.

Can anyone point to good online papers or some other reading that can get one started in the specific matrix transformations applied to the 3D environment? I have found this area of research very hard to find. Many matrix problems are very basic, some are incredibly hard, but none I’ve found are truly 3D oriented and this, I believe, would help in getting focused on the area one is interested instead of dwelving into the depths of complicated math problems (that may be the next step! ). Any pointers would be highly appreciated,

thanks in advanced,

Rafael Polit Jr.
Quito, Ecuador.

Try the Matrix FAQ. I think is a very good reference about matrices, quaternions and vectors.

HTH.

1 Reply
(@hblan)
Joined: 11 months ago

Posts: 0

a very good website for me , but need some time to learn , heh , so thanks again .

Assuming you know what a vector is. You can think of the matrix3 as a 4 x 3 matrix where the first 3 rows represent the direction vectors the objects X Y Z axis and the last row represents the objects world position.

 For example


   Start a new scene in max 

   Create a box somewhere in the LEFT viewport

   Then open up the MAXScript Listener and type this

   [color=Cyan]$Box01.transform[/color]

   [color=White]The Max listener then returns a value like this[/color]

   [color=blue](matrix3 [0,-1,0] [0,0,1] [-1,0,0] [0,12,57.6])

[/color]

If not the type this into the listener.
[color=black][font=&quot][color=Cyan]$Box01.transform =[/color][/color][/font][color=blue] [color=Cyan](matrix3 [0,-1,0] [0,0,1] [-1,0,0] [0,12,57.6])[/color][/color][color=blue][font=&quot][/color][/font]
[color=blue][/color]

   [color=blue][color=White]Looking at the first row we can see that the x-Axis has this vector [0,-1,0] Ie the local x-axis of the object points backwards along the World Space y-axis[/color][/color]

   Now click on the object and pick Local  from the main toolbars Coordinate system dropdown list.

Note the direction the objects X-axis points and compare it with the little icon in the bottom left of the viewport that represents the world axis. You should see the local x-axis of the object points backwards along the World Space y-axis.

   Now type this into the listener window 

   $box01.transform = (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])

   The box now moves to the center of the world (because the last row is now [0,0,0] ) and its local axis are aligned with the world axis.

It’s also worth noting that by tweeking the values of the first 3 row you can also control the objects scale.

   E.g Typing this will squash the box flat. Because the length of the z axis (the 3rd row) is now zero

   $box01.transform = (matrix3 [1,0,0] [0,1,0] [0,0,0] [0,0,0])

Typing this will stretch the box. Because the length of the z axis (the 3rd row) is now 10

   $box01.transform = (matrix3 [1,0,0] [0,1,0] [0,0,10] [0,0,0])

Even more strangely you can shear the box by typing this

   $box01.transform = (matrix3 [1,1,0] [0,1,0] [0,0,1] [0,0,0])

   Because the angle of the x-axis has changed whilst the y and z remain aligned to the world.

I wish this stuff was explained in the Max Help (which I find is normally excellent
) I spent months poking around with object transforms thinking they were some sort of mathematical voodoo (like quaternions) when it’s actually very simple.

enjoy…

ur explain is very good ,so easy to understand . thanks very much . i think this will be at maxscript help ducuments .

so , if i just want change the direction of vector_x or y z, just change the the vector_x and normalize it . right ? haha. thanks .

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

You would like to keep the matrix orthogonal most of the time, so changing one is a bad idea. There is an orthogonalize method in MAXScript to fix such matrices though.

Usually, you take a matrix you have, take another matrix that describes the transformation of the first, and multiply the first by the second. Everything else happens automatically.

For example:

$Teapot01.transform = rotateXMatrix 45 * $Teapot01.transform

This creates a new matrix which has Y and Z axes rotated around the X axis at 45 degrees while preserving the orthogonality. The Translation part (Row4) is [0,0,0]. Then it is transformed into the coordinate space of your teapot, resulting in the rotation matrix using your teapot as a User Coordinate System where the pivot point is the origin and the local X, Y and Z are the coordinate system axes.
As a result, the first matrix is aligned to your teapot, just the Y and Z are rotated at 45 degrees relatively to its local coordinate space like they were relatively to the world before the multiplication.
So when you assign the resulting matrix to the teapot, it rotates about its pivot point and X axis at 45 degrees!

If you switch the places of the operands, the result is a rotation of the teapot at 45 degrees about the WORLD X axis. In this case, the teapot is transformed into the new coordinate system which is rotated relative to the WORLD at 45 degees about X, and the resulting matrix is applied to the transform property.
$Teapot01.transform = $Teapot01.transform * rotateXMatrix 45
or
$Teapot01.transform *= rotateXMatrix 45

You can do this with vectors, too, for example in order to transform one position in space into another coordinate system.

Btw, my DVD is almost ready and will feature alot more on vector operations, barycentric coordinates, matrix operations, and even the basics of lighting and rendering calculations

 PEN

Here is a MatrixModel, it is a working model of how the matrix works and what it does. There is more of an explanation in popup note when you open the file. I think this will help explain just how it work and what it does.

http://paulneale.com/tutorials/matrix/matrixModel.zip

 PEN

I can’t wait for your DVD Bobo:)

My earlier post was more to do with what the Matrix 3 means ( which like i said would be otherwise hard to find.) Mostly you’ll want to use the method Bobo describes for moving or rotating objects.

To get the best out of matrix 3 transforms you need to know about vectors ,quaternions, cross products, dot products…

If you haven’t covered this stuff at college then I’m sure that bobo’s DVD will be a great way to learn it.

yes ,like bobo say . now i am waiting bobo`s dvd for more information and imagination.

Page 1 / 2