improve readability

This commit is contained in:
Josh Hawkins 2024-12-22 18:48:38 -06:00
parent ed572b7c2b
commit e1bb480462

View File

@ -12,18 +12,17 @@ def order_points_clockwise(points):
""" """
center = np.mean(points, axis=0) center = np.mean(points, axis=0)
top_left = points[ top_left = top_right = bottom_right = bottom_left = None
np.logical_and(points[:, 0] < center[0], points[:, 1] < center[1])
][0] for point in points:
top_right = points[ if point[0] < center[0] and point[1] < center[1] and top_left is None:
np.logical_and(points[:, 0] > center[0], points[:, 1] < center[1]) top_left = point
][0] elif point[0] > center[0] and point[1] < center[1] and top_right is None:
bottom_right = points[ top_right = point
np.logical_and(points[:, 0] > center[0], points[:, 1] > center[1]) elif point[0] > center[0] and point[1] > center[1] and bottom_right is None:
][0] bottom_right = point
bottom_left = points[ elif point[0] < center[0] and point[1] > center[1] and bottom_left is None:
np.logical_and(points[:, 0] < center[0], points[:, 1] > center[1]) bottom_left = point
][0]
return np.array([top_left, top_right, bottom_right, bottom_left]) return np.array([top_left, top_right, bottom_right, bottom_left])