I think it would be more accurate to use one of the methods that pulls the
Euler rotation from a matrix like Ryan and Judd suggested.

import math
import maya.OpenMaya as mApi

def getOrient(normal, tangent, ro=0):
    kRotateOrders = [mApi.MEulerRotation.kXYZ, mApi.MEulerRotation.kYZX,
                     mApi.MEulerRotation.kZXY, mApi.MEulerRotation.kXZY,
                     mApi.MEulerRotation.kYXZ, mApi.MEulerRotation.kZYX,]
    cross = [normal[1]*tangent[2] - normal[2]*tangent[1],
         normal[2]*tangent[0] - normal[0]*tangent[2],
         normal[0]*tangent[1] - normal[1]*tangent[0]]
    tMatrix  = normal+[0]+tangent+[0]+cross+[0,0,0,0,1]
    mMatrix  = mApi.MMatrix()
    mApi.MScriptUtil.createMatrixFromList(tMatrix, mMatrix)
    tmMatrix = mApi.MTransformationMatrix(mMatrix)
    rotate   = tmMatrix.eulerRotation().reorder(kRotateOrders[ro])
    RAD_to_DEG    = (180/math.pi)
    return [rotate[0]*RAD_to_DEG,  rotate[1]*RAD_to_DEG,
rotate[2]*RAD_to_DEG]
getOrient([1,0,0], [0,1,0], ro=0)

On Wed, Feb 25, 2009 at 5:55 AM, ugly bob <[email protected]> wrote:

>
>
> interesting. in the interest of ease of use i m gonna stick with the
> quaternion work around. interesting bug. i m trying to get the euler
> rotations, from a translate vector i think? that is to transform a
> torus to the rotation of a face, via queried facenormal values. its
> all good now though. spent ages wrapping that mel script but the API
> goodness comes through again! hurrah !
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to