add/sub coordinates

This commit is contained in:
Stefan Harmuth 2021-11-30 12:11:36 +01:00
parent 02b4f869b9
commit 37211190dd

View File

@ -74,6 +74,12 @@ class Coordinate:
else:
return 180.0 + abs(angle)
def __add__(self, other: Coordinate) -> Coordinate:
return Coordinate(self.x + other.x, self.y + other.y)
def __sub__(self, other: Coordinate) -> Coordinate:
return Coordinate(self.x - other.x, self.y - other.y)
@staticmethod
def generate(from_x: int, to_x: int, from_y: int, to_y: int) -> List[Coordinate]:
return [Coordinate(x, y) for x in range(from_x, to_x + 1) for y in range(from_y, to_y + 1)]