From e3864d8468a0d0d4e6491126cfe26b0e88372a58 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 5 Mar 2023 14:24:44 -0800 Subject: [PATCH] Implement LE, LT, GE, GT on Point --- erynrl/geometry.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/erynrl/geometry.py b/erynrl/geometry.py index 97aee52..0001d56 100644 --- a/erynrl/geometry.py +++ b/erynrl/geometry.py @@ -73,6 +73,18 @@ class Point: raise TypeError('Only Vector can be added to a Point') return Point(self.x - other.dx, self.y - other.dy) + def __lt__(self, other: 'Point') -> bool: + return self.x < other.x and self.y < other.y + + def __le__(self, other: 'Point') -> bool: + return self.x <= other.x and self.y <= other.y + + def __gt__(self, other: 'Point') -> bool: + return self.x > other.x and self.y > other.y + + def __ge__(self, other: 'Point') -> bool: + return self.x >= other.x and self.y >= other.y + def __iter__(self): yield self.x yield self.y