Add Point.euclidean_distance_to()
Does what it says on the tin.
This commit is contained in:
parent
99ca090448
commit
e9db004a7a
1 changed files with 5 additions and 0 deletions
|
@ -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':
|
||||||
...
|
...
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue