MCPcopy Create free account
hub / github.com/FullControlXYZ/fullcontrol / segmented_line

Function segmented_line

fullcontrol/geometry/segmentation.py:6–22  ·  view source on GitHub ↗

Return a list of Points linearly spaced between the start Point and end Point. The total number of Points in the list is segments+1. Parameters: point1 (Point): The start Point of the line segment. point2 (Point): The end Point of the line segment. segments

(point1: Point, point2: Point, segments: int)

Source from the content-addressed store, hash-verified

4
5
6def segmented_line(point1: Point, point2: Point, segments: int) -> list:
7 '''
8 Return a list of Points linearly spaced between the start Point and end Point.
9 The total number of Points in the list is segments+1.
10
11 Parameters:
12 point1 (Point): The start Point of the line segment.
13 point2 (Point): The end Point of the line segment.
14 segments (int): The number of segments to divide the line into.
15
16 Returns:
17 list: A list of Points linearly spaced between the start and end Points.
18 '''
19 x_steps = linspace(point1.x, point2.x, segments+1)
20 y_steps = linspace(point1.y, point2.y, segments+1)
21 z_steps = linspace(point1.z, point2.z, segments+1)
22 return [Point(x=x_steps[i], y=y_steps[i], z=z_steps[i]) for i in range(segments+1)]
23
24
25def segmented_path(points: list, segments: int) -> int:

Callers 1

make_gridFunction · 0.90

Calls 2

linspaceFunction · 0.85
PointClass · 0.50

Tested by

no test coverage detected