Using the Law of cosines and the Law of sines, this library can be used to calculate all remaining sides and angles of a triangle when any one of the following sets of inputs are available.
- The length of 2 adjacent sides and their interior angle (SAS)
- The value of 2 angles and the length of the common side (ASA)
- The lengths of all 3 sides of the triangle (SSS)
pip install trianglesImport the module
from triangles import trianglesUse the functions to calculate the sides and angles of a triangle
>>> triangles.SSS(1,1,1)
(1, 1, 1, 60.00000000000001, 59.99999999999999, 60.00000000000001)
>>> triangles.SAS(1,60,1)
(1, 1, 0.9999999999999999, 60.00000000000001, 60.00000000000001, 60)
>>> triangles.ASA(60,1,60)
(1.0, 1.0, 1, 60, 60, 60)