Add sort_by_rotation

This commit is contained in:
2024-06-11 18:45:16 +02:00
parent 9c215a5d24
commit 229c43c308
4 changed files with 73 additions and 5 deletions

View File

@@ -34,16 +34,16 @@ class Point3D:
"""
return min(points, key=lambda point: self.distance(point))
def optimized_path(self, points: List["Point3D"]):
def optimized_path(self, points: List["Point3D"]) -> List["Point3D"]:
"""Get an optimized ordered path starting from the current point.
From: https://stackoverflow.com/questions/45829155/sort-points-in-order-to-have-a-continuous-curve-using-python
Args:
points (List[Point2D]): List of 3d-points. Could contain the current point.
points (List[Point3D]): List of 3d-points. Could contain the current point.
Returns:
List[Point2D]: Ordered list of 3d-points starting from the current point.
List[Point3D]: Ordered list of 3d-points starting from the current point.
>>> Point3D(-2, -5, 6).optimized_path([Point3D(0, 0, 7), Point3D(10, 5, 1), Point3D(1, 3, 3)])
[Point3D(x: -2, y: -5, z: 6), Point3D(x: 0, y: 0, z: 7), Point3D(x: 1, y: 3, z: 3), Point3D(x: 10, y: 5, z: 1)]