skspatial.objects.LineSegment

class skspatial.objects.LineSegment(point_a: Union[numpy.ndarray, Sequence], point_b: Union[numpy.ndarray, Sequence])[source]

A line segment in space.

The line segment is defined by two points.

Parameters
point_a, point_barray_like

The two endpoints of the line segment.

Raises
ValueError

If the two endpoints are equal.

Examples

>>> from skspatial.objects import LineSegment
>>> segment = LineSegment([0, 0], [1, 0])
>>> segment
LineSegment(point_a=Point([0, 0]), point_b=Point([1, 0]))
>>> LineSegment([0, 0], [0, 0])
Traceback (most recent call last):
...
ValueError: The endpoints must not be equal.
Attributes
point_a, point_bPoint

The two endpoints of the line segment.

Methods

contains_point(point, **kwargs)

Check if a point is on the line segment.

intersect_line_segment(other)

Intersect the line segment with another.

plot_2d(ax_2d, **kwargs)

Plot a 2D line segment.

plot_3d(ax_3d, **kwargs)

Plot a 3D line segment.