CGTalk MTransformationMatrix
 06-22-2013, 10:12 AM #1 andyman121 Veteran portfolio Andrew Brownridge Manchester, United Kingdom   Join Date: Oct 2010 Posts: 75 MTransformationMatrix How does this work from the API documentation? What is it supposed to be? The transformation matrix is then constructed as follows: Code: ``` -1 -1 [Sp]x[S]x[Sh]x[Sp]x[St]x[Rp]x[Ro]x[R]x[Rp]x[Rt]x[T]``` where 'x' denotes matrix multiplication and '-1' denotes matrix inversion Is it supposed to be a matrix in itself? Where are the -1's supposed to sit within the thing? http://download.autodesk.com/us/may...ion_matrix.html I presume the final transform matrix is achieved by multiplying the said 4x4 matrices together in the order given, and to get back from the final transform to a point on the line, [R] for example, you would factor out [T] then [Rt] then [Rp] my multiplying by their inverse? The -1's on the description has confused me though. Am I missing something? Can anyone shed some light on this? Thanks in anticipation share quote
 06-23-2013, 06:47 PM #2 VB2341 Frequenter portfolio Varun Bajaj Troy, US   Join Date: Jan 2013 Posts: 125 I believe Sp and Rp are the scale and rotate pivot matrices. The -1's above them indicate that you don't use those matrices themselves, but their inverse. The wikipedia article describes it pretty well: http://en.wikipedia.org/wiki/Invertible_matrix To get the [R] matrix you have to use its explicit form, shown here: http://download.autodesk.com/us/may...ion_matrix.html Multiplying by the inverses you listed would only chop off the terms that are to the right of the [R] matrix in the product for the transform matrix. Remember, matrix multiplication is not commutative. share quote
 06-24-2013, 09:05 AM #3 andyman121 Veteran portfolio Andrew Brownridge Manchester, United Kingdom   Join Date: Oct 2010 Posts: 75 Thanks for that. That being the case, how come the -1 is only on one of the Sp and Rp in the list and not on the others? I'm not sure what you mean by using it's explicit form - the link you posted is the same link that I posted for the full Tranformation Matrix I get what you mean about chopping the bits off the end of the line, and generally there would only be Translate, Scale and Rotate which are relatively easy to factor out. Do you know also what values Maya uses to display in the Attribute Editor/Channel Box? I presume they are the Euler angles taken from the transformation matrix? Would they be from the world matrices? In the order XYZ? share quote
 06-24-2013, 11:18 AM #4 ThE_JacO MOBerator-X   portfolio Raffaele Fragapane That Creature Dude Animal Logic Sydney, Australia   Join Date: Jul 2002 Posts: 10,954 The panels usually show you the "local" transform, or rather, the transform relative to the parent, which is an object's world transform multiplied by the inverse of the parent's, with the angle being derived from the world orientation based on rotation order, with the spins counted (as a singular 4x4 matrix can't account for spins, only for an orientation, when it comes to rotations). That page might seem confusing because it's telling you what Maya considers to obtain the final transform, which is a long chain of operations on different components to make sure that all things that can affect a transform in maya (such as the pivot) are accounted for. The inversions should be addressing the pivot's behaviour, and without trying, I'd guess it's implied as invert the result of the chain at that point, so first invert the scaling pivot, keep going, then in the chain of operations once you've factored in the rotation pivot invert again and keep moving. Again, without trying and at a guess, without those inversions I'd imagine you would get a double offset from the pivot if it was non-ID instead of it affecting components the way you want it. Have you tried implementing your own reconstruction of it to see it happen at the various stages? It should all become fairly clear compared to trying to figure out the hundreds of operations in your head Most things like missing an inversion should have a visually meaningful repercussion, and show you why it's there (IE: Pivot compensation becomes mirrored or additive instead, matrix changes handedness and stuff like that) __________________ "As an online CG discussion grows longer, the probability of the topic being shifted to subsidies approaches 1" Free Maya Nodes share quote
 06-24-2013, 11:49 AM #5 andyman121 Veteran portfolio Andrew Brownridge Manchester, United Kingdom   Join Date: Oct 2010 Posts: 75 Thanks for the help. I've not tried experimenting yet, no. Just been trying to make sense of it theoretically. It might be better to see visually, that's a good idea. So are we decided that the composition order should read [Sp]-1x[S]x[Sh]x[Sp]x[St]x[Rp]-1x[Ro]x[R]x[Rp]x[Rt]x[T] with the first Sp and Rp being the inverse matrices? That would effectively mean that the scale pivot would be applied after the shear and the rotate pivot would be applied after the rotation right? As you say the panels should show the local transform, would this be to Euler angles in the order XYZ? If I run the following code on joint2 of a simple 3 joint chain: joint1 <0, 5, 0> joint2 <0, 0, 0> joint3 <3, 0, 0> rotate -r -os 0 0 -30; rotate -r -os 0 -60 0 The panel shows rotation to be [40.893, -48.590, -49.107] Whereas if I print the EulerXYZ on the joint I get [163.89788624801398, -25.658906273255269, -56.309932474020236] share quote
 06-24-2013, 12:30 PM #6 andyman121 Veteran portfolio Andrew Brownridge Manchester, United Kingdom   Join Date: Oct 2010 Posts: 75 It would appear that it is object space (local) as the following code retrieves the values displayed in the panels Code: ```import maya.cmds as cmds joints = cmds.ls('joint2') for joint in joints: jntPos = cmds.xform(joint, q=True, ro=True, os=True) print jntPos``` Although the xform docs confuse the matter of composition order and where the inverses go :S http://download.autodesk.com/us/may...ands/xform.html share quote
 07-23-2013, 06:03 PM #7 pinochan New Member portfolio United Kingdom   Join Date: Jul 2013 Posts: 2 aaah, just had to deal with this for a mind blowing animation exporter, maya to game engine. It was fun! ok so, the transformation matrix that you retrive from maya through .transformation().asMatrix() is the information matrix that you need for placement of a particular node in the scene. It is made up from all other matrixes that represent particular fields that you can control, let's say... translation. The translation is represented by the last row. In the 4x4 matrix the translation iformation is m[3,0] = x ; m[3,1] = y; m[3,2] = z where m is a MMatrix = node.transformation().asMatrix(). By multiplying matrixs made of a variety of 1, 0, -1 elements with the transformation matix you can change, it's local rotation orietation, you can change the cartesian orientation from right hand side to left hand side... and scale factors etc. Or, you can alter that by using changing the options with fuctions provided in the MTansformationMatrix class. I ended up doing algebra rather than altering the scene. Hope it helps. share quote
 07-23-2013, 06:03 PM #8 CGTalk Moderation Expert   Join Date: Sep 2003 Posts: 1,066,478 Thread automatically closed 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. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote