Added: Division and scalar multiplication to Vector
This commit is contained in:
parent
6ed8c45e4b
commit
e8364f872e
13
box.py
13
box.py
@ -9,11 +9,24 @@ class Vector(_Vector):
|
||||
|
||||
def __add__(self, other):
|
||||
return Vector(self[0] + other[0], self[1] + other[1], self[2] + other[2])
|
||||
|
||||
def __sub__(self, other):
|
||||
return Vector(self[0] - other[0], self[1] - other[1], self[2] - other[2])
|
||||
|
||||
def __mul__(self, other):
|
||||
if isinstance(other, (int, float)):
|
||||
return Vector(self[0] * other, self[1] * other, self[2] * other)
|
||||
|
||||
return Vector(self[0] * other[0], self[1] * other[1], self[2] * other[2])
|
||||
|
||||
def __truediv__(self, other):
|
||||
if isinstance(other, (int, float)):
|
||||
return Vector(self[0] / other, self[1] / other, self[2] / other)
|
||||
|
||||
return Vector(self[0] / other[0], self[1] / other[1], self[2] / other[2])
|
||||
|
||||
__div__ = __truediv__
|
||||
|
||||
class BoundingBox (object):
|
||||
type = int
|
||||
|
||||
|
Reference in New Issue
Block a user