

def compute(self, plug, dataBlock):
    "Compute the upper arm's elevation angle as well as the orientation for the first twist joint in the shoulder."
    if ((plug == AM_ShoulderConstraintNode.rotate) or (plug == AM_ShoulderConstraintNode.angle)):
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.rotateOrder)
        eRotateOrder = dataHandle.asShort()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.raisedAngleOffset)
        dRaisedAngleOffset = dataHandle.asDouble()
        dRaisedAngleOffset = math.radians(dRaisedAngleOffset)
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.shoulderAim)
        vShoulderForward = dataHandle.asVector().normal()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.shoulderFront)
        vShoulderRight = dataHandle.asVector().normal()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.spineAim)
        vSpineForward = dataHandle.asVector().normal()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.spineFront)
        vSpineUp = dataHandle.asVector().normal()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.shoulderPivot)
        vShoulderPivot = dataHandle.asVector()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.spinePivot)
        vSpinePivot = dataHandle.asVector()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.jointOrient)
        vJointOrient = dataHandle.asVector()
        eJointOrient = OM.MEulerRotation(math.radians(vJointOrient.x), math.radians(vJointOrient.y), math.radians(vJointOrient.z), 0)
        qJointOrient = eJointOrient.asQuaternion()
        qJointOrient.conjugateIt()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.spine)
        mSpine = dataHandle.asMatrix()
        mSpine = OM.MTransformationMatrix(mSpine)
        qSpine = mSpine.rotation()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.shoulder)
        mShoulder = dataHandle.asMatrix()
        mShoulder = OM.MTransformationMatrix(mShoulder)
        qShoulder = mShoulder.rotation()
        dataHandle = dataBlock.inputValue(AM_ShoulderConstraintNode.parentInverseMatrix)
        mParent = dataHandle.asMatrix()
        mParent = OM.MTransformationMatrix(mParent)
        qParent = mParent.rotation()
        vShoulderUp = OM.MVector((vShoulderForward ^ vShoulderRight)).normal()
        vShoulderRight = (vShoulderUp ^ vShoulderForward)
        vSpineRight = OM.MVector((vSpineUp ^ vSpineForward)).normal()
        vSpineUp = (vSpineForward ^ vSpineRight)
        mSpine.addTranslation((- vSpinePivot), OM.MSpace.kObject)
        mShoulder.addTranslation((- vShoulderPivot), OM.MSpace.kObject)
        vSpinePosition = mSpine.getTranslation(OM.MSpace.kWorld)
        vShoulderPosition = mShoulder.getTranslation(OM.MSpace.kWorld)
        dBodySideScalar = cmp(((vSpinePosition - vShoulderPosition) * vSpineRight.rotateBy(qSpine)), 0.0)
        vRest = (vSpineForward * (- dBodySideScalar))
        vLowered = (- (vSpineForward ^ vSpineUp))
        vRaised = (- vSpineRight.rotateBy(OM.MQuaternion(dRaisedAngleOffset, (vSpineForward * (- dBodySideScalar)))))
        vSpineForwardRotated = vSpineForward.rotateBy(qSpine)
        vShoulderForwardRotated = vShoulderForward.rotateBy(qShoulder)
        dAngle = math.degrees((math.pi - vSpineForwardRotated.angle(vShoulderForwardRotated)))
        dDot = (vSpineForwardRotated * vShoulderForwardRotated)
        vTargetUp = OM.MVector()
        if (dDot < 0):
            vTargetUp = (vRest + ((vLowered - vRest) * (- dDot)))
        else:
            vTargetUp = (vRest + ((vRaised - vRest) * dDot))
        vTargetUp = plug.rotateBy(qSpine).normal()
        vTargetRight = (vTargetUp ^ vShoulderForwardRotated)
        vTargetUp = (vShoulderForwardRotated ^ vTargetRight)
        mList = [vTargetRight.x, vTargetRight.y, vTargetRight.z, 0.0, vTargetUp.x, vTargetUp.y, vTargetUp.z, 0.0, vShoulderForwardRotated.x, vShoulderForwardRotated.y, vShoulderForwardRotated.z, 0.0, 0.0, 0.0, 0.0, 1.0]
        mTarget = OM.MMatrix()
        OM.MScriptUtil.createMatrixFromList(mList, mTarget)
        qTarget = OM.MQuaternion(OM.MTransformationMatrix(mTarget).rotation())
        mList = [vShoulderRight.x, vShoulderRight.y, vShoulderRight.z, 0.0, vShoulderUp.x, vShoulderUp.y, vShoulderUp.z, 0.0, vShoulderForward.x, vShoulderForward.y, vShoulderForward.z, 0.0, 0.0, 0.0, 0.0, 1.0]
        mFromNormal = OM.MMatrix()
        OM.MScriptUtil.createMatrixFromList(mList, mFromNormal)
        qFromNormal = OM.MQuaternion(OM.MTransformationMatrix(mFromNormal).rotation())
        if (qFromNormal.w > 0.0):
            qFromNormal.invertIt()
        qFinal = OM.MQuaternion((((qFromNormal * qTarget) * qParent) * qJointOrient))
        eFinal = qFinal.asEulerRotation()
        eFinal.reorderIt(eRotateOrder)
        outputHandle = dataBlock.outputValue(AM_ShoulderConstraintNode.rotate)
        outputHandle.set3Double(math.degrees(eFinal.x), math.degrees(eFinal.y), math.degrees(eFinal.z))
        outputHandle = dataBlock.outputValue(AM_ShoulderConstraintNode.angle)
        outputHandle.setDouble(dAngle)
        dataBlock.setClean(plug)
    else:
        return OM.kUnknownParameter

dataset/ETHPy150Open CountZer0/PipelineConstructionSet/maya/plugins/2014/win64/AM_ShoulderConstraint.py AM_ShoulderConstraintNode.compute/VarMisuse@675/1250 `vTargetUp`->`plug`