skspatial.objects.Triangle.is_right

Triangle.is_right(**kwargs: float) bool[source]

Check if the triangle is a right triangle.

A right triangle with sides \(abc\), satisfies the Pythagorean theorem

\[a^2 + b^2 = c^2\]
Parameters:
kwargsdict, optional

Additional keywords passed to math.isclose().

Returns:
bool

True if the triangle is a right triangle; false otherwise.

Examples

>>> from skspatial.objects import Triangle
>>> Triangle([0, 0], [0, 1], [1, 0]).is_right()
True
>>> Triangle([0, 0], [0, 1], [1, 1]).is_right()
True
>>> Triangle([0, 0], [1, 2], [2, 0]).is_right()
False

This triangle is approximately a right triangle.

>>> triangle = Triangle([0, 0], [100, 0], [101, 100])
>>> triangle.is_right()
False
>>> triangle.is_right(rel_tol=1e-2)
True