add/sub coordinates
This commit is contained in:
parent
02b4f869b9
commit
37211190dd
@ -74,6 +74,12 @@ class Coordinate:
|
|||||||
else:
|
else:
|
||||||
return 180.0 + abs(angle)
|
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
|
@staticmethod
|
||||||
def generate(from_x: int, to_x: int, from_y: int, to_y: int) -> List[Coordinate]:
|
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)]
|
return [Coordinate(x, y) for x in range(from_x, to_x + 1) for y in range(from_y, to_y + 1)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user