skspatial.objects.Triangle

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

A triangle represented by three points in space.

Parameters
point_a, point_b, point_carray_like

The three vertices of the triangle.

Raises
ValueError

If the points do not have the same dimension. If the points are collinear.

Examples

>>> from skspatial.objects import Triangle
>>> triangle = Triangle([0, 0], [1, 0], [0, 1])
>>> triangle
Triangle(point_a=Point([0, 0]), point_b=Point([1, 0]), point_c=Point([0, 1]))
>>> triangle.dimension
2
>>> Triangle([0, 0, 0], [1, 0], [0, 1])
Traceback (most recent call last):
...
ValueError: The points must have the same dimension.
>>> Triangle([0, 0], [0, 1], [0, 2])
Traceback (most recent call last):
...
ValueError: The points must not be collinear.
Attributes
point_a, point_b, point_cPoint

The three vertices of the triangle.

dimensionint

Dimension of the triangle.

Methods

altitude(vertex)

Return the line of an altitude of the triangle.

angle(vertex)

Return an interior angle of the triangle.

area()

Return the area of the triangle.

centroid()

Return the centroid of the triangle.

classify(**kwargs)

Classify the triangle as equilateral, isosceles, or scalene.

is_right(**kwargs)

Check if the triangle is a right triangle.

length(side)

Return a side length of the triangle.

line(side)

Return the line along a side of the triangle.

multiple(name_method, inputs)

Return multiple properties of the triangle.

normal()

Return a vector normal to the triangle.

orthocenter()

Return the orthocenter of the triangle.

perimeter()

Return the perimeter of the triangle.

plot_2d(ax_2d[, part])

Plot a triangle in 2D.

plot_3d(ax_3d[, part])

Plot a triangle in 3D.

point(vertex)

Return a point (vertex) of the triangle.