Fix length issue on last segment
This commit is contained in:
@@ -126,7 +126,6 @@ class Polyline:
|
|||||||
list[Segment2D]: List of segments in order.
|
list[Segment2D]: List of segments in order.
|
||||||
"""
|
"""
|
||||||
# Get first segment.
|
# Get first segment.
|
||||||
# segments index is 0, corresponding to the first points_array to the first point ([0]) of the first arc (acrs_intersections[1]).
|
|
||||||
# First arc index is 1 because index 0 is None due to fix list lenght. Is it a good choice?
|
# First arc index is 1 because index 0 is None due to fix list lenght. Is it a good choice?
|
||||||
self.segments[1] = Segment2D(Point2D.from_arrays(
|
self.segments[1] = Segment2D(Point2D.from_arrays(
|
||||||
self.points_array[0]), self.acrs_intersections[1][0])
|
self.points_array[0]), self.acrs_intersections[1][0])
|
||||||
@@ -136,10 +135,10 @@ class Polyline:
|
|||||||
self.segments[i] = Segment2D(Point2D(self.acrs_intersections[i][0].x, self.acrs_intersections[i][0].y), Point2D(
|
self.segments[i] = Segment2D(Point2D(self.acrs_intersections[i][0].x, self.acrs_intersections[i][0].y), Point2D(
|
||||||
self.acrs_intersections[i-1][-1].x, self.acrs_intersections[i-1][-1].y))
|
self.acrs_intersections[i-1][-1].x, self.acrs_intersections[i-1][-1].y))
|
||||||
|
|
||||||
# Get last segment. Index is -2 because last index -1 should be None due to the same list lenght.
|
# Why -3?
|
||||||
# For n points, there are n-1 segments.
|
# For n points, there are n-1 segments.
|
||||||
# self.segments[-2] = Segment2D(self.acrs_intersections[-2][2], Point2D.from_arrays(
|
self.segments[-3] = Segment2D(self.acrs_intersections[-2][2], Point2D.from_arrays(
|
||||||
# self.points_array[-1]))
|
self.points_array[-1]))
|
||||||
|
|
||||||
return self.segments
|
return self.segments
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Road:
|
|||||||
|
|
||||||
self.polyline = Polyline(Point3D.to_2d(coordinates, 'y'))
|
self.polyline = Polyline(Point3D.to_2d(coordinates, 'y'))
|
||||||
self._surface()
|
self._surface()
|
||||||
|
self._projection()
|
||||||
|
|
||||||
def _surface(self):
|
def _surface(self):
|
||||||
# Segments
|
# Segments
|
||||||
@@ -49,7 +50,11 @@ class Road:
|
|||||||
180+i])[0].coordinates, Block("black_concrete")))
|
180+i])[0].coordinates, Block("black_concrete")))
|
||||||
|
|
||||||
def _projection(self):
|
def _projection(self):
|
||||||
pass
|
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]))
|
||||||
|
print(nearest_points_to_reference)
|
||||||
|
|
||||||
def place(self):
|
def place(self):
|
||||||
editor = Editor(buffering=True)
|
editor = Editor(buffering=True)
|
||||||
|
|||||||
BIN
output_image.png
BIN
output_image.png
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.3 KiB |
Reference in New Issue
Block a user