Skip to content

Commit

Permalink
Merge pull request #63 from FCrSTATS/added_distance_to_point
Browse files Browse the repository at this point in the history
Update pitch.py
  • Loading branch information
koenvo authored Sep 26, 2020
2 parents 2749793 + e305e0f commit 17ccd75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kloppy/domain/models/pitch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
from math import sqrt


@dataclass
Expand All @@ -25,3 +26,7 @@ class PitchDimensions:
class Point:
x: float
y: float

def distance_to(self, other: "Point") -> float:
# returns the euclidean distance between the point and another provided point
return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2)

0 comments on commit 17ccd75

Please sign in to comment.