def setup(self, axis=None):
        """
		sets up the initial state of the pair node
		"""

        if axis:
            axis = abs(Axis(axis))
            setAttr("%s.axis" % self.node, axis)

            # if we have two controls try to auto determine the orientAxis and the flipAxes
        if self.controlA and self.controlB:
            worldMatrixA = getWorldRotMatrix(self.controlA)
            worldMatrixB = getWorldRotMatrix(self.controlB)

            # so restPoseB = restPoseA * offsetMatrix
            # restPoseAInv * restPoseB = restPoseAInv * restPoseA * offsetMatrix
            # restPoseAInv * restPoseB = I * offsetMatrix
            # thus offsetMatrix = restPoseAInv * restPoseB
            offsetMatrix = worldMatrixA.inverse() * worldMatrixB

            AXES = AX_X.asVector(), AX_Y.asVector(), AX_Z.asVector()
            flippedAxes = []
            for n in range(3):
                axisNVector = Vector(offsetMatrix[n][:3])

                # if the axes are close to being opposite, then consider it a flipped axis...
                if axisNVector.dot(AXES[n]) < -0.8:
                    flippedAxes.append(n)

            for n, flipAxes in enumerate(self.FLIP_AXES):
                if tuple(flippedAxes) == flipAxes:
                    setAttr("%s.flipAxes" % self.node, n)
                    break

                    # this is a bit of a hack - and not always true, but generally singular controls built by skeleton builder will work with this value
        elif self.controlA:
            setAttr("%s.flipAxes" % self.node, 1)
            self.setWorldSpace(False)
    def setup(self, axis=None):
        '''
		sets up the initial state of the pair node
		'''

        if axis:
            axis = abs(Axis(axis))
            setAttr('%s.axis' % self.node, axis)

        #if we have two controls try to auto determine the orientAxis and the flipAxes
        if self.controlA and self.controlB:
            worldMatrixA = getWorldRotMatrix(self.controlA)
            worldMatrixB = getWorldRotMatrix(self.controlB)

            #so restPoseB = restPoseA * offsetMatrix
            #restPoseAInv * restPoseB = restPoseAInv * restPoseA * offsetMatrix
            #restPoseAInv * restPoseB = I * offsetMatrix
            #thus offsetMatrix = restPoseAInv * restPoseB
            offsetMatrix = worldMatrixA.inverse() * worldMatrixB

            AXES = AX_X.asVector(), AX_Y.asVector(), AX_Z.asVector()
            flippedAxes = []
            for n in range(3):
                axisNVector = Vector(offsetMatrix[n][:3])

                #if the axes are close to being opposite, then consider it a flipped axis...
                if axisNVector.dot(AXES[n]) < -0.8:
                    flippedAxes.append(n)

            for n, flipAxes in enumerate(self.FLIP_AXES):
                if tuple(flippedAxes) == flipAxes:
                    setAttr('%s.flipAxes' % self.node, n)
                    break

        #this is a bit of a hack - and not always true, but generally singular controls built by skeleton builder will work with this value
        elif self.controlA:
            setAttr('%s.flipAxes' % self.node, 1)
            self.setWorldSpace(False)
Beispiel #3
0
import numpy as np
from vectors import Point, Vector
import functools

v1 = Vector(1, 2, 3)
v2 = Vector(10, 20, 30)
print(v1.add(10))
print(v1.sum(v2))  # displays <1 22 33>

print(v1.magnitude())

#We can multiply a vector by a real number.

print(v2.multiply(4))  #=> Vector(4.0, 8.0, 12.0)
print(v1.dot(v2))
print(v1.dot(v2, 180))
print(v1.cross(v2))

print(v1.angle(v2))

print(v1.parallel(v2))
print(v1.perpendicular(v2))
#print(v1.non_parallel(v2))