From cc9a6bcbc57aed0bbe39965bba0d309a5c6dffbe Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Sun, 17 Sep 2023 04:07:47 +0200 Subject: [PATCH] Coordinate.__mul__, Coordinate.__truediv__, Coordinate.__floordiv__ --- tools/coordinate.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/coordinate.py b/tools/coordinate.py index a27d7bb..0871fe4 100644 --- a/tools/coordinate.py +++ b/tools/coordinate.py @@ -176,6 +176,21 @@ class Coordinate: else: 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): if not isinstance(other, Coordinate): return False