shapes.polyline#
- shapes.polyline(points, div=1, closed=False)#
Create a polyline.
A polyline is a connected sequence of straight line segments defined by a list of vertices.
Parameters#
- points: coords_like
An (npts,3) shaped array with the coordinates of the subsequent vertices of the polyline, or any other data accepted by the
Coordsinitialization.- divint or list of int, optional
Subdivision specification along the segments:
If int: all segments are equally subdivided into
divparts.If list of int: specifies the number of subdivisions for each segment between consecutive points. The length of the list must match the number of segments.
- closedbool, optional
If True, the polyline is closed by connecting the last vertex back to the first. The closed polyline then has
nptssegments. Default is False, leaving the curve open withnpts - 1segments.
Returns#
- Mesh
A line mesh (
eltype="line2") representing the polyline.
Examples#
>>> pts = [[0.0, 0.0, 0.0], [3.0, 0.0, 0.0], [7.0, 4.0, 0.0]] >>> M1 = polyline(pts, div=[1, 2, 3], closed=True) >>> print(M1) Mesh: n_nodes: 6, n_elems: 6, plexitude: 2, level: 1, eltype: line2 BBox: [0. 0. 0.], [7. 4. 0.] Size: [7. 4. 0.] Length: 16.72 >>> M2 = polyline(pts, div=2, closed=False) >>> print(M2) Mesh: n_nodes: 5, n_elems: 4, plexitude: 2, level: 1, eltype: line2 BBox: [0. 0. 0.], [7. 4. 0.] Size: [7. 4. 0.] Length: 8.657