Diff of /geometry.py [000000] .. [2c38ce]

Switch to unified view

a b/geometry.py
1
from math import pow, sqrt
2
import matplotlib.path as mpltPath
3
4
def euclidianDistance (p1, p2):
5
   return sqrt((pow((p2[0] - p1[0]), 2)) + (pow((p2[1] - p1[1]), 2)))
6
7
def isPointsInsidePolygon (points, polygon):
8
   path = mpltPath.Path(polygon)
9
   return path.contains_points(points)
10
11
def distanceToPolygon (p, polygon):
12
   minDistance = euclidianDistance(p, polygon[0])
13
   for i in range(1, len(polygon)):
14
      distance = euclidianDistance(p, polygon[i])
15
      if distance < minDistance:
16
         minDistance = distance
17
   return minDistance