You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
621 B
23 lines
621 B
import math |
|
|
|
from .points import Point |
|
|
|
|
|
class Math: |
|
""" |
|
Defines useful static helper methods for mathematical functions in |
|
Computational Geometry. |
|
""" |
|
|
|
@classmethod |
|
def euclidean_distance(cls, p1, p2): |
|
""" |
|
Given two points of type Point, returns the euclidean distance between |
|
those two points. |
|
""" |
|
|
|
if not isinstance(p1, Point) or not isinstance(p2, Point): |
|
raise ValueError("Euclidean distance can only be calculated " + |
|
"on points") |
|
|
|
return math.sqrt(math.pow(p2.x - p1.x, 2) + math.pow(p2.y - p1.y, 2))
|
|
|