Add Point.euclidean_distance_to()

Does what it says on the tin.
This commit is contained in:
Eryn Wells 2022-05-12 08:46:45 -07:00
parent 99ca090448
commit e9db004a7a

View file

@ -2,6 +2,7 @@
'''A bunch of geometric primitives''' '''A bunch of geometric primitives'''
import math
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Iterator, Optional, overload from typing import Any, Iterator, Optional, overload
@ -35,6 +36,10 @@ class Point:
return None return None
def euclidean_distance_to(self, other: 'Point') -> float:
'''Compute the Euclidean distance to another Point'''
return math.sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2)
@overload @overload
def __add__(self, other: 'Vector') -> 'Point': def __add__(self, other: 'Vector') -> 'Point':
... ...