Cool. Looks about like what I have now, aside from using an MScriptUtil to create the MMatrix from the raw data. Thanks for the clarification!
On Wed, Jul 18, 2012 at 4:16 PM, Adam Mechtley <[email protected]>wrote: > Well not quite sure that's what I had in mind. Maybe this is easier ;) > > *import* Maya.OpenMaya *as* om > matrix = om.MMatrix() *# has index operator* > *# set matrix elements from sensor data using index operator here* > transformation_matrix = om.MTransformationMatrix(matrix) *# has no index > operator, but has methods for getting rotation* > transformation_matrix.reorderRotation(om.MTransformationMatrix.kZXY) *# > or whatever rotation order you need* > euler_rotation = transformation_matrix.eulerRotation() > z_rotation = euler_rotation.z *# note: this is in radians* > *# do whatever you need to do with z_rotation,* > *# such as create new MEulerRotation and apply* > *# to another transform with MFnTransform.setRotation()* > > On Wed, Jul 18, 2012 at 5:37 PM, Justin Israel <[email protected]>wrote: > >> Our rigs only move in XY and rotate in Z, so the sensor data has >> information I don't always want to apply. Ultimately I have to map the raw >> sensor data to different axis based on various conditions. I get what you >> are saying so far, and I just wanted to make sure this is the most >> efficient approach: >> 1. Raw data -> MMatrix -> Euler -> Euler.z >> 2. get objects MTransformationMatrix -> euler >> 3. Set objects euler.z = to this euler.z >> 4. MTransMatrix setRotation( updated euler ) >> >> I was just doubting myself because of the number of objects and >> conversions and thought there was some better way that I was missing. >> >> >> On Wed, Jul 18, 2012 at 9:12 AM, Adam Mechtley >> <[email protected]>wrote: >> >>> Hi Justin, >>> >>> I'm not 100% clear on the needs (i.e., why only one axis is desired, >>> which prevents you from using a much cleaner quaternion-based solution), >>> but if you're only wanting to extract rotation about a single axis from a >>> matrix that has rotation about all three axes, then you need to select some >>> decomposition order if you want it as Euler angles (e.g., XYZ, ZXY, >>> etc.)—probably just whatever is being used by the transform you are piping >>> it to. In Maya, there is an MTransformationMatrix constructor that accepts >>> an MMatrix. Thereafter, you can call reorderRotation on the transformation >>> matrix to set your desired decomposition order and simply get its >>> eulerRotation. >>> >>> Sorry if I missed what you need to do a bit, but hopefully there's >>> something helpful here >>> >>> >>> On Tue, Jul 17, 2012 at 5:15 PM, Justin Israel >>> <[email protected]>wrote: >>> >>>> Hey all. >>>> >>>> My current project right now has an aspect which is not my forté. >>>> Hopefully you guys with strong matrix manipulation skills can advise the >>>> "pipeline" guy... >>>> I'm dev'ing a library that reads and delivers Kinect sensor data to >>>> Maya. The joint orientation data is delivered as 3x3 rotation matrices. As >>>> of now to get the concept working, I am converting them to Euler on the >>>> library side (via >>>> cgkit<http://cgkit.sourceforge.net/doc2/mat3.html#mat3.toEulerXYZ>), >>>> and then piping them into maya over my socket. Within Maya, for this >>>> specific example, I am just interested in applying the rotZ to my >>>> component. And I am doing that very basically right now with a rotate >>>> command to see live results. >>>> >>>> What I would like to do is just send my 3x3 rotation matrix in its raw >>>> form and apply the rotZ via the API to the rotation of the transform. I >>>> will always be applying transformations by discrete axis (usually I only >>>> care about rz, and for translation I only care about tx/ty). >>>> >>>> Can someone give me a quick workflow suggestion of 3x3 rotation matrix >>>> -> add rz to QTransformationMatrix ? >>>> I know I will need to pad it out to 4x4, and create an MMatrix, but >>>> once I have that I am pretty weak on the concept of the matrix operations. >>>> >>>> -- >>>> view archives: http://groups.google.com/group/python_inside_maya >>>> change your subscription settings: >>>> http://groups.google.com/group/python_inside_maya/subscribe >>>> >>> >>> -- >>> view archives: http://groups.google.com/group/python_inside_maya >>> change your subscription settings: >>> http://groups.google.com/group/python_inside_maya/subscribe >>> >> >> -- >> view archives: http://groups.google.com/group/python_inside_maya >> change your subscription settings: >> http://groups.google.com/group/python_inside_maya/subscribe >> > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
