From 44ae995c2d025eccbba9f2ce6c51aeac775ba0f8 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 30 Jan 2022 18:39:31 +0300 Subject: [PATCH] basictypes: Point: Added Eucledian distance from another point. Signed-off-by: HeshamTB --- basictypes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/basictypes.py b/basictypes.py index 1586e03..beea2e2 100644 --- a/basictypes.py +++ b/basictypes.py @@ -35,6 +35,11 @@ class Point: def apply_cartesian_shift(self, x, y) -> None: pass + def distance_from_point(self, point) -> float: + # Euclidian distance + distance = math.sqrt((self.get_x() - point.get_x())**2 + (self.get_y() - point.get_y())**2) + return distance + class PointWithID(Point):