line_segments_from_points

line_segments_from_points#

line_segments_from_points(points: VectorLike[float] | MatrixLike[float]) PolyData[source]#

Generate non-connected line segments from points.

Assumes points are ordered as line segments and an even number of points.

Parameters:
pointsarray_like[float]

Points representing line segments. An even number must be given as every two vertices represent a single line segment. For example, two line segments would be represented as np.array([[0, 0, 0], [1, 0, 0], [1, 0, 0], [1, 1, 0]]).

Returns:
pyvista.PolyData

PolyData with lines and cells.

Examples

This example plots two line segments at right angles to each other.

>>> import pyvista as pv
>>> import numpy as np
>>> points = np.array([[0, 0, 0], [1, 0, 0], [1, 0, 0], [1, 1, 0]])
>>> lines = pv.line_segments_from_points(points)
>>> lines.plot()
../../../_images/pyvista-line_segments_from_points-0fb212404c1f0d90_00_00.png