+= operators
This commit is contained in:
parent
e865bf4c6d
commit
67ee904c9e
24
obja.py
24
obja.py
|
@ -47,15 +47,39 @@ class Vector:
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
return Vector(self.x + other.x, self.y + other.y, self.z + other.z)
|
return Vector(self.x + other.x, self.y + other.y, self.z + other.z)
|
||||||
|
|
||||||
|
def __iadd__(self, other):
|
||||||
|
self.x += other.x
|
||||||
|
self.y += other.y
|
||||||
|
self.z += other.z
|
||||||
|
return self
|
||||||
|
|
||||||
def __sub__(self, other):
|
def __sub__(self, other):
|
||||||
return Vector(self.x - other.x, self.y - other.y, self.z - other.z)
|
return Vector(self.x - other.x, self.y - other.y, self.z - other.z)
|
||||||
|
|
||||||
|
def __isub__(self, other):
|
||||||
|
self.x -= other.x
|
||||||
|
self.y -= other.y
|
||||||
|
self.z -= other.z
|
||||||
|
return self
|
||||||
|
|
||||||
def __mul__(self, other):
|
def __mul__(self, other):
|
||||||
return Vector(self.x * other, self.y * other, self.z * other)
|
return Vector(self.x * other, self.y * other, self.z * other)
|
||||||
|
|
||||||
|
def __imul__(self, other):
|
||||||
|
self.x *= other
|
||||||
|
self.y *= other
|
||||||
|
self.z *= other
|
||||||
|
return self
|
||||||
|
|
||||||
def __truediv__(self, other):
|
def __truediv__(self, other):
|
||||||
return Vector(self.x / other, self.y / other, self.z / other)
|
return Vector(self.x / other, self.y / other, self.z / other)
|
||||||
|
|
||||||
|
def __itruediv__(self, other):
|
||||||
|
self.x /= other
|
||||||
|
self.y /= other
|
||||||
|
self.z /= other
|
||||||
|
return self
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return str(self)
|
return str(self)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue