Midpoint circle and circle intersection

This commit is contained in:
NichiHachi
2024-05-27 23:00:16 +02:00
parent 93ea5d6f18
commit 2244dd7b85
2 changed files with 136 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
from math import sqrt
from math import sqrt, atan2
class Position:
@@ -21,12 +21,19 @@ class Position:
def __str__(self):
return f"({self.x}, {self.y})"
def __eq__(self, other: "Position"):
return self.x == other.x and self.y == other.y
def distance_to(self, other: "Position") -> float:
return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2)
def norm(self) -> float:
return sqrt(self.x ** 2 + self.y ** 2)
def angle_to(self, other: "Position") -> float:
return atan2(self.y - other.y, other.x - self.x)
class Station:
"""
This class represents the position and link of a metro station.