def normalize( self ):
		"Normalizes the vector"

		length = breveInternal.vectorLength( self )

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

        length = breveInternal.vectorLength(self)

        if length != 0.0:
            return breveInternal.scaleVector(self, 1.0 / length)
	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 )
Esempio 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)
	def scale( self, other ):
		"Scales the vector by a scalar"
		return breveInternal.scaleVector( self, -1 )
	def __neg__( self ):
		return breveInternal.scaleVector( self, -1 )
	def __div__( self, other ):
		return breveInternal.scaleVector( self, 1.0 / other )
Esempio n. 8
0
 def scale(self, other):
     "Scales the vector by a scalar"
     return breveInternal.scaleVector(self, other)
Esempio n. 9
0
 def __neg__(self):
     return breveInternal.scaleVector(self, -1)
Esempio n. 10
0
 def __div__(self, other):
     return breveInternal.scaleVector(self, 1.0 / other)