Coordinate.__mul__, Coordinate.__truediv__, Coordinate.__floordiv__

This commit is contained in:
Stefan Harmuth 2023-09-17 04:07:47 +02:00
parent ec64dce347
commit cc9a6bcbc5

View File

@ -176,6 +176,21 @@ class Coordinate:
else: else:
return self.__class__(self.x - other.x, self.y - other.y, self.z - other.z) return self.__class__(self.x - other.x, self.y - other.y, self.z - other.z)
def __mul__(self, other: int) -> Coordinate:
if self.z is None:
return self.__class__(self.x * other, self.y * other)
else:
return self.__class__(self.x * other, self.y * other, self.z * other)
def __floordiv__(self, other) -> Coordinate:
if self.z is None:
return self.__class__(self.x // other, self.y // other)
else:
return self.__class__(self.x // other, self.y // other, self.z // other)
def __truediv__(self, other):
return self // other
def __eq__(self, other): def __eq__(self, other):
if not isinstance(other, Coordinate): if not isinstance(other, Coordinate):
return False return False