MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / euclidean_distance

Method euclidean_distance

geometry/graham_scan.py:80–89  ·  view source on GitHub ↗

Calculate Euclidean distance between two points. >>> Point(0, 0).euclidean_distance(Point(3, 4)) 5.0 >>> Point(1, 1).euclidean_distance(Point(4, 5)) 5.0

(self, other: Point)

Source from the content-addressed store, hash-verified

78 return self.y < other.y
79
80 def euclidean_distance(self, other: Point) -> float:
81 """
82 Calculate Euclidean distance between two points.
83
84 >>> Point(0, 0).euclidean_distance(Point(3, 4))
85 5.0
86 >>> Point(1, 1).euclidean_distance(Point(4, 5))
87 5.0
88 """
89 return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5
90
91 def consecutive_orientation(self, point_a: Point, point_b: Point) -> float:
92 """

Callers 3

test_euclidean_distanceFunction · 0.95
polar_angle_keyFunction · 0.80
compare_pointsFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_euclidean_distanceFunction · 0.76