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)
| 4 | |
| 5 | |
| 6 | def 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 | |
| 25 | def segmented_path(points: list, segments: int) -> int: |