skspatial.objects.Triangle.altitude

Triangle.altitude(vertex: str) skspatial.objects.line.Line[source]

Return the line of an altitude of the triangle.

An altitude is a line segment through a vertex and perpendicular to the opposite side.

Parameters
vertex: str

‘A’, ‘B’, or ‘C’.

Returns
Line

Altitude line.

Raises
ValueError

If the vertex is not ‘A’, ‘B’, or ‘C’.

Examples

>>> from skspatial.objects import Triangle
>>> triangle = Triangle([0, 0], [1, 1], [2, 0])
>>> triangle.altitude('A')
Line(point=Point([0, 0]), direction=Vector([1., 1.]))
>>> triangle.altitude('B')
Line(point=Point([1, 1]), direction=Vector([ 0., -1.]))
>>> triangle.altitude('C')
Line(point=Point([2, 0]), direction=Vector([-1.,  1.]))
>>> triangle.altitude('D')
Traceback (most recent call last):
...
ValueError: The vertex must be 'A', 'B', or 'C'.