Ejemplo n.º 1
0
	def normalize( self ):
		"Normalizes the vector"

		length = breveInternal.vectorLength( self )

		if length != 0.0:
			return breveInternal.scaleVector( self, 1.0 / length )
Ejemplo n.º 2
0
    def normalize(self):
        "Normalizes the vector"

        length = breveInternal.vectorLength(self)

        if length != 0.0:
            return breveInternal.scaleVector(self, 1.0 / length)
Ejemplo n.º 3
0
	def __mul__( self, other ):
		if type( other ) == float or type( other ) == int:
			return breveInternal.scaleVector( self, other )

		if other.__class__ == matrix:
			x = self[ 0 ] * other[ 0 ] + self[ 1 ] * other[ 1 ] + self[ 2 ] * other[ 2 ]
			y = self[ 0 ] * other[ 3 ] + self[ 1 ] * other[ 4 ] + self[ 2 ] * other[ 5 ]
			z = self[ 0 ] * other[ 6 ] + self[ 1 ] * other[ 7 ] + self[ 2 ] * other[ 8 ]

			return vector( x, y, z )
Ejemplo n.º 4
0
    def __mul__(self, other):
        if type(other) == float or type(other) == int:
            return breveInternal.scaleVector(self, other)

        if other.__class__ == matrix:
            x = self[0] * other[0] + self[1] * other[1] + self[2] * other[2]
            y = self[0] * other[3] + self[1] * other[4] + self[2] * other[5]
            z = self[0] * other[6] + self[1] * other[7] + self[2] * other[8]

            return vector(x, y, z)
Ejemplo n.º 5
0
	def scale( self, other ):
		"Scales the vector by a scalar"
		return breveInternal.scaleVector( self, -1 )
Ejemplo n.º 6
0
	def __neg__( self ):
		return breveInternal.scaleVector( self, -1 )
Ejemplo n.º 7
0
	def __div__( self, other ):
		return breveInternal.scaleVector( self, 1.0 / other )
Ejemplo n.º 8
0
 def scale(self, other):
     "Scales the vector by a scalar"
     return breveInternal.scaleVector(self, other)
Ejemplo n.º 9
0
 def __neg__(self):
     return breveInternal.scaleVector(self, -1)
Ejemplo n.º 10
0
 def __div__(self, other):
     return breveInternal.scaleVector(self, 1.0 / other)