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

Function angle_comparer

other/graham_scan.py:28–48  ·  view source on GitHub ↗

Return the angle toward to point from (minx, miny) :param point: The target point minx: The starting point's x miny: The starting point's y :return: the angle Examples: >>> angle_comparer((1,1), 0, 0) 45.0 >>> angle_comparer((100,1), 10, 10) -5.71

(point: tuple[int, int], minx: int, miny: int)

Source from the content-addressed store, hash-verified

26
27
28def angle_comparer(point: tuple[int, int], minx: int, miny: int) -> float:
29 """Return the angle toward to point from (minx, miny)
30
31 :param point: The target point
32 minx: The starting point's x
33 miny: The starting point's y
34 :return: the angle
35
36 Examples:
37 >>> angle_comparer((1,1), 0, 0)
38 45.0
39
40 >>> angle_comparer((100,1), 10, 10)
41 -5.710593137499642
42
43 >>> angle_comparer((5,5), 2, 3)
44 33.690067525979785
45 """
46 # sort the points accorgind to the angle from the lowest and the most left point
47 x, y = point
48 return degrees(atan2(y - miny, x - minx))
49
50
51def check_direction(

Callers 1

graham_scanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected