skspatial.objects.Triangle.length

Triangle.length(side: str) float64[source]

Return a side length of the triangle.

Side ‘a’ is the side across from vertex ‘A’. The side length is the distance between vertices ‘B’ and ‘C’.

Parameters:
side: str

‘a’, ‘b’, or ‘c’.

Returns:
np.float64

Side length.

Raises:
ValueError

If the side is not ‘a’, ‘b’, or ‘c’.

Examples

>>> from skspatial.objects import Triangle
>>> triangle = Triangle([0, 0], [1, 0], [0, 1])
>>> triangle.length('a').round(3)
np.float64(1.414)
>>> triangle.length('b')
np.float64(1.0)
>>> triangle.length('c')
np.float64(1.0)
>>> triangle.length('d')
Traceback (most recent call last):
...
ValueError: The side must be 'a', 'b', or 'c'.