MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _euclidean_distance

Function _euclidean_distance

geometry/ramer_douglas_peucker.py:19–30  ·  view source on GitHub ↗

Return the Euclidean distance between two 2-D points. >>> _euclidean_distance((0.0, 0.0), (3.0, 4.0)) 5.0 >>> _euclidean_distance((1.0, 1.0), (1.0, 1.0)) 0.0

(
    point_a: tuple[float, float],
    point_b: tuple[float, float],
)

Source from the content-addressed store, hash-verified

17
18
19def _euclidean_distance(
20 point_a: tuple[float, float],
21 point_b: tuple[float, float],
22) -> float:
23 """Return the Euclidean distance between two 2-D points.
24
25 >>> _euclidean_distance((0.0, 0.0), (3.0, 4.0))
26 5.0
27 >>> _euclidean_distance((1.0, 1.0), (1.0, 1.0))
28 0.0
29 """
30 return math.hypot(point_b[0] - point_a[0], point_b[1] - point_a[1])
31
32
33def _perpendicular_distance(

Callers 1

_perpendicular_distanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected