compas_cgal.polylines
¤
Polyline utilities using CGAL.
Functions¤
closest_points_on_polyline
¤
Find closest points on a polyline for a batch of query points.
Uses CGAL's AABB tree for efficient batch queries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_points
|
PointsList
|
Query points as Mx2 or Mx3 array. |
required |
polyline
|
PointsList
|
Polyline as Nx2 or Nx3 array. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Closest points on the polyline (same shape as query_points). |
Examples:
simplify_polyline
¤
simplify_polyline(polyline: PointsList, threshold: float) -> NDArray
Simplify a single polyline using Douglas-Peucker algorithm.
Simplification is performed in the XY plane only. For 3D polylines, Z coordinates are preserved but not considered in distance calculations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polyline
|
PointsList
|
Sequence of 2D or 3D points. |
required |
threshold
|
float
|
Distance threshold for simplification. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Simplified polyline as numpy array. |
simplify_polylines
¤
Simplify multiple polylines using Douglas-Peucker algorithm.
Simplification is performed in the XY plane only. For 3D polylines, Z coordinates are preserved but not considered in distance calculations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polylines
|
list[PointsList]
|
List of polylines. Each polyline is a sequence of 2D or 3D points. |
required |
threshold
|
float
|
Distance threshold for simplification. Higher values remove more points. |
required |
Returns:
| Type | Description |
|---|---|
list of ndarray
|
Simplified polylines as numpy arrays. |
Examples: