Rename files
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
import networks.geometry.curve as curve
|
||||
import networks.geometry.segment as segment
|
||||
import networks.geometry.curve_tools as curve_tools
|
||||
import networks.geometry.segment_tools as segment_tools
|
||||
import numpy as np
|
||||
|
||||
|
||||
class CurveSurface:
|
||||
class Strip:
|
||||
def __init__(self, points, reshape=True, spacing_distance=10):
|
||||
self.points = np.array(points)
|
||||
if reshape:
|
||||
self.resolution, self.length = curve.resolution_distance(
|
||||
self.resolution, self.length = curve_tools.resolution_distance(
|
||||
self.points, spacing_distance=spacing_distance)
|
||||
self.curve = curve.curve(self.points, self.resolution)
|
||||
self.curve = curve_tools.curve(self.points, self.resolution)
|
||||
else: # Point can also be given already in curved form
|
||||
self.curve = self.points
|
||||
|
||||
def compute_curvature(self):
|
||||
self.curvature = curve.curvature(self.curve)
|
||||
self.curvature = curve_tools.curvature(self.curve)
|
||||
|
||||
def compute_surface_perpendicular(self, width, normals):
|
||||
self.offset_left = curve.offset(self.curve, width, normals)
|
||||
self.offset_right = curve.offset(self.curve, -width, normals)
|
||||
self.offset_left = curve_tools.offset(self.curve, width, normals)
|
||||
self.offset_right = curve_tools.offset(self.curve, -width, normals)
|
||||
self.perpendicular_segment = []
|
||||
|
||||
for i in range(len(self.offset_left)):
|
||||
self.perpendicular_segment.append(segment.discrete_segment(
|
||||
self.perpendicular_segment.append(segment_tools.discrete_segment(
|
||||
self.offset_left[i], self.offset_right[i], pixel_perfect=False))
|
||||
|
||||
self.surface = []
|
||||
@@ -45,14 +45,14 @@ class CurveSurface:
|
||||
|
||||
self.surface[i].append([])
|
||||
for k in range(len(self.perpendicular_segment[max_length_index])-1):
|
||||
self.surface[i][j].append(segment.discrete_segment(
|
||||
self.surface[i][j].append(segment_tools.discrete_segment(
|
||||
self.perpendicular_segment[max_length_index][k], self.perpendicular_segment[min_length_index][round(k * proportion)], pixel_perfect=False))
|
||||
|
||||
def compute_surface_parallel(self, inner_range, outer_range, resolution, normals):
|
||||
self.left_side = []
|
||||
self.right_side = []
|
||||
for current_range in range(inner_range * resolution, outer_range * resolution):
|
||||
self.left_side.append(curve.offset(
|
||||
self.left_side.append(curve_tools.offset(
|
||||
self.curve, current_range/resolution, normals))
|
||||
self.right_side.append(curve.offset(
|
||||
self.right_side.append(curve_tools.offset(
|
||||
self.curve, -current_range/resolution, normals))
|
||||
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
import networks.geometry.segment as segment
|
||||
import networks.geometry.segment_tools as segment_tools
|
||||
from scipy import interpolate
|
||||
from math import sqrt
|
||||
|
||||
@@ -83,14 +83,14 @@ def offset(curve, distance, normals):
|
||||
'Number of normals and number of points in the curve do not match')
|
||||
|
||||
# Offsetting
|
||||
offset_segments = [segment.parallel(
|
||||
offset_segments = [segment_tools.parallel(
|
||||
(curve[i], curve[i+1]), distance, normals[i]) for i in range(len(curve) - 1)]
|
||||
|
||||
# Combining segments
|
||||
combined_curve = []
|
||||
combined_curve.append(np.round(offset_segments[0][0]).tolist())
|
||||
for i in range(0, len(offset_segments)-1):
|
||||
combined_curve.append(segment.middle_point(
|
||||
combined_curve.append(segment_tools.middle_point(
|
||||
offset_segments[i][1], offset_segments[i+1][0]))
|
||||
combined_curve.append(np.round(offset_segments[-1][1]).tolist())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import networks.geometry.curve as curve
|
||||
import networks.geometry.CurveSurface as CurveSurface
|
||||
import networks.geometry.segment as segment
|
||||
import networks.geometry.curve_tools as curve_tools
|
||||
import networks.geometry.Strip as Strip
|
||||
import networks.geometry.segment_tools as segment_tools
|
||||
import random
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@ class Lane:
|
||||
self.surface = []
|
||||
|
||||
def get_surface(self):
|
||||
resolution, distance = curve.resolution_distance(self.coordinates, 6)
|
||||
resolution, distance = curve_tools.resolution_distance(
|
||||
self.coordinates, 6)
|
||||
|
||||
curve_points = curve.curve(self.coordinates, resolution)
|
||||
curve_surface = CurveSurface.CurveSurface(self.coordinates)
|
||||
curve_points = curve_tools.curve(self.coordinates, resolution)
|
||||
curve_surface = Strip.Strip(self.coordinates)
|
||||
curve_surface.compute_curvature()
|
||||
|
||||
# Set the road to be flat
|
||||
@@ -25,9 +26,9 @@ class Lane:
|
||||
|
||||
# Compute each line
|
||||
for distance in range(self.width):
|
||||
offset = curve.offset(curve_surface.curve, distance, normals)
|
||||
offset = curve_tools.offset(curve_surface.curve, distance, normals)
|
||||
for i in range(len(offset)-1):
|
||||
line = segment.discrete_segment(offset[i], offset[i+1])
|
||||
line = segment_tools.discrete_segment(offset[i], offset[i+1])
|
||||
for coordinate in line:
|
||||
self.surface.append((coordinate, random.choices(
|
||||
list(self.lane_materials.keys()),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import networks.geometry.curve as curve
|
||||
import networks.geometry.segment as segment
|
||||
import networks.geometry.curve_tools as curve_tools
|
||||
import networks.geometry.segment_tools as segment_tools
|
||||
import random
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ class Line:
|
||||
self.surface = []
|
||||
|
||||
def get_surface(self):
|
||||
resolution, distance = curve.resolution_distance(self.coordinates, 6)
|
||||
resolution, distance = curve_tools.resolution_distance(
|
||||
self.coordinates, 6)
|
||||
|
||||
curve_points = curve.curve(self.coordinates, resolution)
|
||||
curve_points = curve_tools.curve(self.coordinates, resolution)
|
||||
|
||||
# Compute the line
|
||||
|
||||
@@ -26,7 +27,8 @@ class Line:
|
||||
|
||||
pattern_iteration = 0
|
||||
for i in range(len(curve_points)-1):
|
||||
line = segment.discrete_segment(curve_points[i], curve_points[i+1])
|
||||
line = segment_tools.discrete_segment(
|
||||
curve_points[i], curve_points[i+1])
|
||||
for coordinate in line:
|
||||
block = random.choices(
|
||||
list(pattern_materials[pattern_iteration].keys()),
|
||||
|
||||
Reference in New Issue
Block a user