trianglesolver

raw JSON →
1.2 verified Sat May 09 auth: no python

A Python library for solving triangles (finding all sides and angles) using the Law of Sines and Law of Cosines. Current version is 1.2, released with no recent updates.

pip install trianglesolver
error ValueError: not enough values to unpack (expected 6, got 0)
cause Calling solve() without providing any named arguments, or missing required arguments.
fix
Always provide exactly three named arguments. Example: solve(a=3, b=4, c=5)
error ValueError: math domain error
cause Impossible triangle (e.g., sides violating triangle inequality) or out-of-range angle values.
fix
Verify your input forms a valid triangle. For angles, use the degree helper correctly.
error ImportError: cannot import name 'trianglesolver' from 'trianglesolver'
cause Trying to import the library name directly instead of the solve function.
fix
Use from trianglesolver import solve instead of from trianglesolver import trianglesolver.
gotcha Angles are returned in radians, not degrees. Use the `degree` helper to convert or handle manually.
fix Convert using `from trianglesolver import degree` or multiply by 180/π.
gotcha The function `solve` requires exactly three arguments out of six possible (a,b,c,A,B,C). Missing or extra arguments will cause an error.
fix Ensure you provide exactly three known values. For example: `solve(a=3, b=4, C=degree(90))`.
deprecated No breaking changes known, but library is very simple and may not handle ambiguous cases (e.g., SSA) with clear errors.
fix Check if the input leads to ambiguous triangle; library may raise an exception or return unexpected results.

Solve triangle given three sides (SSS). Returns sides a,b,c and angles A,B,C in radians.

from trianglesolver import solve, degree
# SSS case: sides a=3, b=4, c=5
a, b, c, A, B, C = solve(a=3, b=4, c=5)
print(f"Angles: A={A:.2f}, B={B:.2f}, C={C:.2f}")