Working first step projection
This commit is contained in:
@@ -72,7 +72,7 @@ class Point2D:
|
||||
else:
|
||||
return (s_p <= 0) and (t_p <= 0) and (s_p + t_p) >= d
|
||||
|
||||
def nearest(self, points: List["Point2D"]) -> "Point2D":
|
||||
def nearest(self, points: List["Point2D"], return_index: bool = False) -> Union["Point2D", List[Union["Point2D", int]]]:
|
||||
"""Return the nearest point. If multiple nearest point, returns the first in the list.
|
||||
|
||||
Args:
|
||||
@@ -81,6 +81,9 @@ class Point2D:
|
||||
Returns:
|
||||
Point2D: The nearest point, and if multiple, the first in the list.
|
||||
"""
|
||||
if return_index:
|
||||
return min(
|
||||
enumerate(points), key=lambda pair: self.distance(pair[1]))
|
||||
return min(points, key=lambda point: self.distance(point))
|
||||
|
||||
def optimized_path(self, points: List["Point2D"]) -> List["Point2D"]:
|
||||
|
||||
@@ -61,7 +61,6 @@ class Polyline:
|
||||
self.get_arcs_intersections()
|
||||
self.get_arcs()
|
||||
self.get_segments()
|
||||
print("\nlekj\n", self.segments, "\nklj\n")
|
||||
|
||||
self.total_line_output = []
|
||||
for i in range(1, self.length_polyline-1):
|
||||
|
||||
@@ -52,9 +52,12 @@ class Road:
|
||||
def _projection(self):
|
||||
nearest_points_to_reference = []
|
||||
for i in range(len(self.coordinates)):
|
||||
nearest_points_to_reference.append(Point3D.insert_3d([Point3D.to_2d([self.coordinates[i]], 'y')[0].nearest(
|
||||
self.polyline.total_line_output)], 'y', [self.coordinates[i].y])[0])
|
||||
print(nearest_points_to_reference)
|
||||
# nearest_points_to_reference.append(Point3D.insert_3d([Point3D.to_2d([self.coordinates[i]], 'y')[0].nearest(
|
||||
# self.polyline.total_line_output, return_index=True)], 'y', [self.coordinates[i].y])[0])
|
||||
index, point = Point3D.to_2d([self.coordinates[i]], 'y')[0].nearest(
|
||||
self.polyline.total_line_output, return_index=True)
|
||||
nearest_points_to_reference.append(
|
||||
Point2D(index, self.coordinates[i].y))
|
||||
|
||||
def place(self):
|
||||
editor = Editor(buffering=True)
|
||||
|
||||
Reference in New Issue
Block a user