Hey gang, I've been trying to understand and analyze a strange, possibly buggy behaviour of *MTransformationMatrix::getRotation()*.
There's a fair chance I am just doing something incredibly stupid here -- or I might have found a weird bug... I've broken it down to an isolated "unit test" scenario (details below). (This is in 2017 SP3 on Windows, btw...) If anybody would be so kind to have quick look if they can confirm/repro or embarrass me by explaining my error that would be really appreciated. Thanks a bunch in advance! :) Cheers, Martin *Description:* *Maya C++ API: * *MTransformationMatrix::getRotation() *ignores rotationOrder *Details:* *a.) --------------------* As per these API docs <http://download.autodesk.com/us/maya/2010help/api/class_m_transformation_matrix.html#40e18d9755eb686be054a7ce03645298> *MTransformationMatrix::getRotation()* accepts a *RotationOrder* argument in which the resulting euler rotation values will get returned. This RotationOrder argument seems to get ignored. *b.) --------------------* If you explicitely call *MTransformationMatrix::reorderRotation() *beforehand then *getRotation()* returns the correct euler values. *c) --------------------* Now this is the strangest part... If you already called *getRotation()* on *_ANY_* *MTransformationMatrix* object before calling* reorderRotation() *as detailed in *b.) *then *getRotation() *will again return the *incorrect *values. *Repro:* I have implemented a C++ command named *mch_Repro* that can be called in two modes. I know I know, please bear with me... The* source code* and the* resulting output* can be found in this this GitHub gist. <https://gist.github.com/martin-chatterjee/5ee158227100eec2db47a6a561e5fa28> The compiled .mll (for Maya 2017 SP3 @ Windows) can be downloaded from my Google Drive. <https://drive.google.com/open?id=0B_FWHhcLYaXwbTJSYndNbmNoR3M> *Breakdowns of what is happening in mch_Repro:* *Breakdown of Mode 01: calling mch_Repro() without an argument will prove a.) and b.)* *// !!! Pseudo Code -- working code can be found in the Gist !!!* *// create two separate MTransformationMatrix objects* MTransformationMatrix testMatrix_A; MTransformationMatrix testMatrix_B; *// initialise them both with the same Euler rotation values in XYZ rotation order* startRotation = ( 180.0, 90.0, -45.0 ); testMatrix_A.setRotation( startRotation, XYZ ); testMatrix_B.setRotation( startRotation, XYZ ); *// now read back the rotation values of testMatrix_A in XYZ rotation order* retrieveRotation_XYZ = testMatrix_A.getRotation( XYZ ); *// compare them with the startRotation:* *// IDENTICAL AS EXPECTED* *// now explicitely set the rotationOrder of testMatrix_B to ZXY * *// (this should not be necessary in my opinion)* testMatrix_B.reorderRotation( ZXY ); *// now read back the rotation values of testMatrix_B in ZXY rotation order* retrieveRotation_ZXY = testMatrix_B.getRotation( ZXY ); *// compare them with the startRotation:* *// DIFFERENT AS EXPECTED* *Breakdown of Mode 02: calling mch_Repro(True) with the 'True' argument will provoke c.) * *// !!! Pseudo Code -- working code can be found in the Gist !!!* *// create two separate MTransformationMatrix objects* MTransformationMatrix testMatrix_A; MTransformationMatrix testMatrix_B; *// initialise them both with the same Euler rotation values in XYZ rotation order* startRotation = ( 180.0, 90.0, -45.0 ); testMatrix_A.setRotation( startRotation, XYZ ); testMatrix_B.setRotation( startRotation, XYZ ); *// now read back the rotation values of testMatrix_A in XYZ rotation order* retrieveRotation_XYZ = testMatrix_A.getRotation( XYZ ); *// compare them with the startRotation:* *// IDENTICAL AS EXPECTED* *// now try to read back the rotation values of testMatrix_A in a different ZXY rotation order* retrieveRotation_ZXY = testMatrix_A.getRotation( XZY ); *// compare them with the startRotation:* *// THEY ARE IDENTICAL --> the rotationOrder argument gets ignored* *// and now on to the strangest part: * *now explicitely set the rotationOrder of testMatrix_B to ZXY * *// (this should not be necessary in my opinion)* testMatrix_B.reorderRotation( ZXY ); *// now read back the rotation values of testMatrix_B in ZXY rotation order* retrieveRotation_ZXY = testMatrix_B.getRotation( ZXY ); *// compare them with the startRotation:* *// THEY ARE IDENTICAL --> the rotationOrder argument also gets ignored here* *// The only difference in executed code to Mode 01 was operating on a different * // MTransformationMatrix object -- but this still fails now ?!?!? -- Martin Chatterjee [ Freelance Technical Director ] [ http://www.chatterjee.de ] [ https://vimeo.com/chatterjee ] -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f4561d4f-8a8d-47df-b69c-de85a949cf4d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
