super.
I think this is mostly working:
import maya.cmds as mc
import maya.OpenMaya as om
import math
import maya.mel as mel
def findAngle():
selectedJoint = mc.ls(selection=True, long=True, type='joint')
parentJoint = mc.listRelatives(selectedJoint, parent=True, type='joint')
childJoint = mc.listRelatives(selectedJoint, children=True, type='joint')
position1 = om.MVector(*mc.xform(selectedJoint, query=True,
worldSpace=True, translation=True))
position2 = om.MVector(*mc.xform(parentJoint, query=True, worldSpace=True,
translation=True))
position3 = om.MVector(*mc.xform(childJoint, query=True, worldSpace=True,
translation=True))
vector1Normalize = (position1 - position2).normal()
vector2Normalize = (position1 - position3).normal()
angleDOT = math.acos(vector1Normalize * vector2Normalize)
print 'angleDOT:', angleDOT
longAngle = angleDOT - (2 * math.pi)
print 'LONG Angle:', longAngle
# This should be cross product? its not working
#angleBetweenCross = math.acos(vector1Normalize^vector2Normalize)
#print 'angleBetweenCross', angleBetweenCross
radians = angleDOT
print 'DEGREES:', mel.eval('rad_to_deg({radians});'.format(radians=radians))
findAngle()
i have a problem with the cross product? I thought it was the "^" symbol but
its giving an error like it needs a float or something? now I just have to
figure out a good test weather or not to use the long angle or the short angle.
because there might be some times when the short angle is really what I want.
--
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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.