4 by 4 Matrix in maya

by denilson020898 posted 113 days ago | 2 comments

There is an entry about matrix resources. Here I want to delve a bit deeper about matrix, especially how we can construct/compose a matrix

I know in maya we have something called bounding box, which is acting like a container for geometry. The bounding box behaves like parallelogram. I tried to created an openGL locator node without defining the proper bounding box. Everytime I hit "F" key to focus the view, It messed up the camera.

http://sk.uploads.im/t/JVBvn.jpg "Matrix"

a11, a12, a13 to represent the x coordinate

a21, a22, a23 to represent the y coordinate

a31, a32, a33 to represent the z coordinate

a41, a42, a43 to represent offset / translation for each individual axis.

Some on internet said the fourth column represents the perspective foreshortening (Don`t know what that means.)

let`s say, I have a locator node that is the child transform1, and transform1 is the child of transform2. When I alter the position of transform1 and transform2. How do I calculate the locator position?

I really have to learn more about linear algebra.

Thanks

by chalk posted 53 days ago

Ok, so matrices in Maya and Max are 4x4 because they need to have an identity ie they need to be invertible - in max you dont have access to the 4th row but in Maya you do which is always [0, 0, 0, 1].

A matrix is a transform made up of 3 unit vectors (x, y and z) which governs its orientation and a w vector being it’s positional offset from the origin. Scale is really just a byproduct of each unit vector - the length of which is its scale in that axis. These unit vectors should be Othogonal to each other ie 90 degrees perpendicular else you get shearing.

All transforms are relative to something even if they’re not parent to anything. Their either relative to the world or a parent and this in Maya is their xformMatrix attr - it’s their local transform with respect to a parent space.

When you get an objects transform with respect to another you multiply its world transform by the inverse of the other - this is what the xformMatrix is - the local inverse.

And there’s an attr for it - The patentInverseMatrix that every transform in Maya has - it’s just the inverse of an transforms parent world matrix.

So why this inverse? Well matrix multiplication is actually more akin to plus/minus. If we reduce the dimensionslity to 1d we can explain.

If we have an object A at 20, 20 being a representation of its transform. And object B being at 30, how do we get Bs transform relative to As.

Ok so let’s do our inversion as before but use addition instead: B(30) + -A (-20) = 10. 10 is the local difference between the two! We can validate this by multiplying (adding in this case): 10 + A(20) = 30!

Maya has attrs that return all aspects of a transform worldMatrix, worldInverseMatrix, parentInverse and a bunch of nodes to do any multiplication.

There’s also the API 2.0 with MMatrix and MTransformationMatrix that can do all the respective functions.

Note though an objects transform is govern by two things - firstly it’s world transform is the product of all its parents local xforms. (Unless there’s some constraint overriding it) and all transform are dictated by their order-of-operation ie the order in which there t r and s channels are multiplied together.

Note - constraints are special in that they interfere with this local space. They work in world space and will essentially change an objects local value so that its stuck in the world even though it’s parented.

by vshotarov posted 113 days ago

I am by no means an expert, but here is how I think about transformation matrices.

So, if you have the following hierarchy:

- transform2
    - transform1
        - locator1

All you have to do in order to calculate the locator1's position is to multiply the local matrices going upwards through the hierarchy. So in this case it would be:

locator1_matrix * transform1_matrix * transform2_matrix , where the matrices are in local space (the matrix attribute of a transform node)

That will give you the locator transformation in the space of whatever the parent of transform2 is, which in this case is world, hence this will be enough. That being said, in Maya you can use the worldMatrix attribute of any transform which is exactly the same as the multiplication above.

So to get your locator's world transform using the worldMatrix attr, you would do this:

locator1_matrix * transform1_worldMatrix which is equivalent to the locator1.worldMatrix attribute.

As other people have mentioned in the other post, there are a few videos at Cult of Rig that go over math concepts. Here are a couple

http://www.cultofrig.com/2017/06/17/pilot-season-day-8-trigonometry/ http://www.cultofrig.com/2017/06/04/pilot-season-day-5/

As for the perspective foreshortening I can't be of much help as I've always used higher level tools to construct my projection matrices in OpenGL (they were similar to this one), so I am not quite sure how that fits in the last column, especially since I haven't done any OpenGL drawing in Maya.