Triangle Solvers
Overview
Triangle geometry is a foundational topic in mathematics, surveying, CAD, and engineering because many spatial problems reduce to recovering unknown sides or angles from partial measurements. This category centers on triangle solving, the process of reconstructing a full triangle from a valid minimal set of known quantities. In analytical workflows, these tools turn sparse geometric observations into complete, internally consistent models. That makes them useful for design validation, coordinate reconstruction, and error checking in measurement pipelines.
The shared mathematical basis is the combination of the Law of Sines, the Law of Cosines, and the angle-sum identity A+B+C=\pi. In compact form,
\frac{a}{\sin A}=\frac{b}{\sin B}=\frac{c}{\sin C}, \qquad c^2=a^2+b^2-2ab\cos C.
These relations define when a triangle is uniquely determined and when ambiguity can appear, especially in side-side-angle (SSA) configurations where two distinct triangles may satisfy the same givens. Understanding that ambiguity is critical in production calculations, because valid inputs can map to multiple geometric outcomes unless a branch rule is explicitly selected.
Implementation is powered by the trianglesolver Python package, which provides robust routines for standard triangle-constraint patterns and a general-purpose solver interface. The library is designed for practical numerical triangle reconstruction in radian measure, returning complete side and angle sets in a consistent structure. Within this category, it serves as the computational backend for all specialized and general triangle workflows.
The direct-pattern solvers handle the most common textbook input structures with clear geometric intent. TRI_SSS solves the three-side case by recovering all angles from side lengths, while TRI_SAS solves two sides plus included angle to recover the remaining side and angles. TRI_AAAS handles three known angles plus one reference side to set scale, producing a unique similar-triangle realization when the angle set is valid. These functions are typically preferred in engineering spreadsheets because they map cleanly to specific measurement setups and provide predictable, single-configuration outputs.
The ambiguity-aware and general interfaces support mixed or uncertain measurement regimes. TRI_SSA addresses the non-included angle case directly and exposes branch handling (forbid, acute, obtuse) so analysts can control ambiguous two-solution scenarios instead of accepting implicit behavior. TRI_SOLVE generalizes the workflow by accepting any valid set of three independent inputs across sides and opposite angles, making it the most flexible entry point for heterogeneous data feeds. In practice, this pair is useful for field-survey backsolves, batch validation pipelines, and diagnostic recalculation when input completeness varies across records.
Taken together, these tools form a coherent triangle-solving stack: use specialized solvers when the constraint type is known, then use the general solver when input patterns vary or must be inferred. This combination supports both high-throughput spreadsheet usage and rigorous geometric QA, while preserving explicit control over edge cases such as SSA ambiguity.
TRI_AAAS
This function solves a triangle when all three angles and one side length are known. The known side sets the scale, and the remaining sides follow from the Law of Sines.
With known angles and one side f opposite angle F:
\frac{d}{\sin(D)} = \frac{e}{\sin(E)} = \frac{f}{\sin(F)}
This determines side lengths uniquely when the angle set is valid for a triangle.
Excel Usage
=TRI_AAAS(D, E, F, f)
D(float, required): First known angle (radians).E(float, required): Second known angle (radians).F(float, required): Third known angle (radians).f(float, required): Known side opposite angle F (length units).
Returns (list[list]): A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
Example 1: Solve from angle triplet summing to pi with side scale one
Inputs:
| D | E | F | f |
|---|---|---|---|
| 1 | 1.1 | 1.041592653589793 | 1 |
Excel formula:
=TRI_AAAS(1, 1.1, 1.041592653589793, 1)
Expected output:
| Result | ||
|---|---|---|
| 0.974817 | 1.03243 | 1 |
| 1 | 1.1 | 1.04159 |
Example 2: Solve from balanced angle set and larger known side
Inputs:
| D | E | F | f |
|---|---|---|---|
| 0.9 | 1 | 1.2415926535897932 | 12 |
Excel formula:
=TRI_AAAS(0.9, 1, 1.2415926535897932, 12)
Expected output:
| Result | ||
|---|---|---|
| 9.93334 | 10.6707 | 12 |
| 0.9 | 1 | 1.24159 |
Example 3: Solve from mixed-angle geometry with known opposite side
Inputs:
| D | E | F | f |
|---|---|---|---|
| 0.5 | 1.2 | 1.4415926535897932 | 7 |
Excel formula:
=TRI_AAAS(0.5, 1.2, 1.4415926535897932, 7)
Expected output:
| Result | ||
|---|---|---|
| 3.38419 | 6.57911 | 7 |
| 0.5 | 1.2 | 1.44159 |
Example 4: Solve from equal first two angles and scaled side
Inputs:
| D | E | F | f |
|---|---|---|---|
| 1 | 1 | 1.1415926535897931 | 9 |
Excel formula:
=TRI_AAAS(1, 1, 1.1415926535897931, 9)
Expected output:
| Result | ||
|---|---|---|
| 8.32867 | 8.32867 | 9 |
| 1 | 1 | 1.14159 |
Python Code
Show Code
from trianglesolver import aaas as trianglesolver_aaas
def tri_aaas(D, E, F, f):
"""
Solve a triangle from three angles and one side for scale.
See: https://pypi.org/project/trianglesolver/
This example function is provided as-is without any representation of accuracy.
Args:
D (float): First known angle (radians).
E (float): Second known angle (radians).
F (float): Third known angle (radians).
f (float): Known side opposite angle F (length units).
Returns:
list[list]: A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
"""
try:
result = trianglesolver_aaas(D, E, F, f)
return [[result[0], result[1], result[2]], [result[3], result[4], result[5]]]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRI_SAS
This function solves a triangle given two sides and the included angle between them (SAS configuration). It computes the third side and all three angles.
The core relationship is the Law of Cosines:
f^2 = d^2 + e^2 - 2de\cos(F)
Once the third side is found, remaining angles are recovered from trigonometric identities. All angles are in radians.
Excel Usage
=TRI_SAS(d, e, F)
d(float, required): First known side length (length units).e(float, required): Second known side length (length units).F(float, required): Included angle between sides d and e (radians).
Returns (list[list]): A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
Example 1: Solve with right included angle
Inputs:
| d | e | F |
|---|---|---|
| 3 | 4 | 1.5707963267948966 |
Excel formula:
=TRI_SAS(3, 4, 1.5707963267948966)
Expected output:
| Result | ||
|---|---|---|
| 3 | 4 | 5 |
| 0.643501 | 0.927295 | 1.5708 |
Example 2: Solve with acute included angle
Inputs:
| d | e | F |
|---|---|---|
| 5 | 6 | 1 |
Excel formula:
=TRI_SAS(5, 6, 1)
Expected output:
| Result | ||
|---|---|---|
| 5 | 6 | 5.3462 |
| 0.905899 | 1.23569 | 1 |
Example 3: Solve with obtuse included angle
Inputs:
| d | e | F |
|---|---|---|
| 7 | 8 | 2.2 |
Excel formula:
=TRI_SAS(7, 8, 2.2)
Expected output:
| Result | ||
|---|---|---|
| 7 | 8 | 13.3758 |
| 0.436878 | 0.504715 | 2.2 |
Example 4: Solve with equal sides and sixty-degree included angle
Inputs:
| d | e | F |
|---|---|---|
| 10 | 10 | 1.0471975511965976 |
Excel formula:
=TRI_SAS(10, 10, 1.0471975511965976)
Expected output:
| Result | ||
|---|---|---|
| 10 | 10 | 10 |
| 1.0472 | 1.0472 | 1.0472 |
Python Code
Show Code
from trianglesolver import sas as trianglesolver_sas
def tri_sas(d, e, F):
"""
Solve a triangle from two sides and their included angle.
See: https://pypi.org/project/trianglesolver/
This example function is provided as-is without any representation of accuracy.
Args:
d (float): First known side length (length units).
e (float): Second known side length (length units).
F (float): Included angle between sides d and e (radians).
Returns:
list[list]: A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
"""
try:
result = trianglesolver_sas(d, e, F)
return [[result[0], result[1], result[2]], [result[3], result[4], result[5]]]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRI_SOLVE
This function solves a triangle when exactly three independent values are known across the three sides and three opposite angles. It returns all sides and all angles in a structured 2D output.
The solver applies standard trigonometric triangle relationships, primarily the Law of Sines and Law of Cosines:
\frac{a}{\sin(A)} = \frac{b}{\sin(B)} = \frac{c}{\sin(C)}
c^2 = a^2 + b^2 - 2ab\cos(C)
In side-side-angle (SSA) cases, two geometric solutions can exist. The ssa_flag option controls how ambiguous SSA cases are handled.
Excel Usage
=TRI_SOLVE(a, b, c, A, B, C, ssa_flag)
a(float, optional, default: null): Side length opposite angle A (length units).b(float, optional, default: null): Side length opposite angle B (length units).c(float, optional, default: null): Side length opposite angle C (length units).A(float, optional, default: null): Angle opposite side a (radians).B(float, optional, default: null): Angle opposite side b (radians).C(float, optional, default: null): Angle opposite side c (radians).ssa_flag(str, optional, default: “forbid”): SSA ambiguity handling mode.
Returns (list[list]): A 2D array where the first row is [a, b, c] and the second row is [A, B, C].
Example 1: Solve all values from three known sides
Inputs:
| a | b | c |
|---|---|---|
| 3 | 4 | 5 |
Excel formula:
=TRI_SOLVE(3, 4, 5)
Expected output:
| Result | ||
|---|---|---|
| 3 | 4 | 5 |
| 0.643501 | 0.927295 | 1.5708 |
Example 2: Solve from two sides and included angle
Inputs:
| a | b | C |
|---|---|---|
| 5 | 6 | 0.9 |
Excel formula:
=TRI_SOLVE(5, 6, 0.9)
Expected output:
| Result | ||
|---|---|---|
| 5 | 6 | 4.86861 |
| 0.934776 | 1.30682 | 0.9 |
Example 3: Solve from two angles and one side
Inputs:
| A | B | c |
|---|---|---|
| 1 | 0.8 | 7 |
Excel formula:
=TRI_SOLVE(1, 0.8, 7)
Expected output:
| Result | ||
|---|---|---|
| 6.04848 | 5.15634 | 7 |
| 1 | 0.8 | 1.34159 |
Example 4: Solve ambiguous SSA by selecting acute branch
Inputs:
| a | b | A | ssa_flag |
|---|---|---|---|
| 8 | 10 | 0.6 | acute |
Excel formula:
=TRI_SOLVE(8, 10, 0.6, "acute")
Expected output:
| Result | ||
|---|---|---|
| 8 | 10 | 13.9206 |
| 0.6 | 0.783556 | 1.75804 |
Python Code
Show Code
from trianglesolver import solve as trianglesolver_solve
def tri_solve(a=None, b=None, c=None, A=None, B=None, C=None, ssa_flag='forbid'):
"""
Solve a triangle from any valid combination of three known side/angle values.
See: https://pypi.org/project/trianglesolver/
This example function is provided as-is without any representation of accuracy.
Args:
a (float, optional): Side length opposite angle A (length units). Default is None.
b (float, optional): Side length opposite angle B (length units). Default is None.
c (float, optional): Side length opposite angle C (length units). Default is None.
A (float, optional): Angle opposite side a (radians). Default is None.
B (float, optional): Angle opposite side b (radians). Default is None.
C (float, optional): Angle opposite side c (radians). Default is None.
ssa_flag (str, optional): SSA ambiguity handling mode. Valid options: Forbid, Acute, Obtuse. Default is 'forbid'.
Returns:
list[list]: A 2D array where the first row is [a, b, c] and the second row is [A, B, C].
"""
try:
result = trianglesolver_solve(a=a, b=b, c=c, A=A, B=B, C=C, ssa_flag=ssa_flag)
return [[result[0], result[1], result[2]], [result[3], result[4], result[5]]]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRI_SSA
This function solves side-side-angle (SSA) triangle inputs, where two sides and one non-included angle are known.
SSA can be ambiguous because the sine relationship may admit two valid angle solutions:
\sin(E) = \frac{e\sin(D)}{d}
Depending on geometry, there can be zero, one, or two triangles. The ssa_flag parameter chooses how to resolve ambiguous two-solution cases.
Excel Usage
=TRI_SSA(d, e, D, ssa_flag)
d(float, required): Known side opposite angle D (length units).e(float, required): Second known side (length units).D(float, required): Known non-included angle opposite side d (radians).ssa_flag(str, optional, default: “forbid”): SSA ambiguity handling mode.
Returns (list[list]): A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
Example 1: Solve SSA using acute branch selection
Inputs:
| d | e | D | ssa_flag |
|---|---|---|---|
| 8 | 10 | 0.6 | acute |
Excel formula:
=TRI_SSA(8, 10, 0.6, "acute")
Expected output:
| Result | ||
|---|---|---|
| 8 | 10 | 13.9206 |
| 0.6 | 0.783556 | 1.75804 |
Example 2: Solve SSA using obtuse branch selection
Inputs:
| d | e | D | ssa_flag |
|---|---|---|---|
| 8 | 10 | 0.6 | obtuse |
Excel formula:
=TRI_SSA(8, 10, 0.6, "obtuse")
Expected output:
| Result | ||
|---|---|---|
| 8 | 10 | 2.58609 |
| 0.6 | 2.35804 | 0.183556 |
Example 3: Solve SSA case with effectively unique geometry
Inputs:
| d | e | D | ssa_flag |
|---|---|---|---|
| 9 | 6 | 0.8 | acute |
Excel formula:
=TRI_SSA(9, 6, 0.8, "acute")
Expected output:
| Result | ||
|---|---|---|
| 9 | 6 | 12.0843 |
| 0.8 | 0.498647 | 1.84295 |
Example 4: Solve SSA with small known angle
Inputs:
| d | e | D | ssa_flag |
|---|---|---|---|
| 9 | 11 | 0.5 | acute |
Excel formula:
=TRI_SSA(9, 11, 0.5, "acute")
Expected output:
| Result | ||
|---|---|---|
| 9 | 11 | 16.9464 |
| 0.5 | 0.62607 | 2.01552 |
Python Code
Show Code
from trianglesolver import ssa as trianglesolver_ssa
def tri_ssa(d, e, D, ssa_flag='forbid'):
"""
Solve a triangle from two sides and a non-included angle using SSA branch selection.
See: https://pypi.org/project/trianglesolver/
This example function is provided as-is without any representation of accuracy.
Args:
d (float): Known side opposite angle D (length units).
e (float): Second known side (length units).
D (float): Known non-included angle opposite side d (radians).
ssa_flag (str, optional): SSA ambiguity handling mode. Valid options: Forbid, Acute, Obtuse. Default is 'forbid'.
Returns:
list[list]: A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
"""
try:
result = trianglesolver_ssa(d, e, D, ssa_flag)
return [[result[0], result[1], result[2]], [result[3], result[4], result[5]]]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRI_SSS
This function solves a triangle when all three side lengths are known. It computes all three angles and returns the complete triangle.
The computation uses the Law of Cosines to recover angles from side lengths:
D = \cos^{-1}\!\left(\frac{e^2 + f^2 - d^2}{2ef}\right),\quad E = \cos^{-1}\!\left(\frac{d^2 + f^2 - e^2}{2df}\right),\quad F = \cos^{-1}\!\left(\frac{d^2 + e^2 - f^2}{2de}\right)
Angles are returned in radians.
Excel Usage
=TRI_SSS(d, e, f)
d(float, required): First side length (length units).e(float, required): Second side length (length units).f(float, required): Third side length (length units).
Returns (list[list]): A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
Example 1: Solve classic 3-4-5 triangle
Inputs:
| d | e | f |
|---|---|---|
| 3 | 4 | 5 |
Excel formula:
=TRI_SSS(3, 4, 5)
Expected output:
| Result | ||
|---|---|---|
| 3 | 4 | 5 |
| 0.643501 | 0.927295 | 1.5708 |
Example 2: Solve equilateral triangle from equal sides
Inputs:
| d | e | f |
|---|---|---|
| 6 | 6 | 6 |
Excel formula:
=TRI_SSS(6, 6, 6)
Expected output:
| Result | ||
|---|---|---|
| 6 | 6 | 6 |
| 1.0472 | 1.0472 | 1.0472 |
Example 3: Solve isosceles triangle from two equal sides
Inputs:
| d | e | f |
|---|---|---|
| 5 | 5 | 8 |
Excel formula:
=TRI_SSS(5, 5, 8)
Expected output:
| Result | ||
|---|---|---|
| 5 | 5 | 8 |
| 0.643501 | 0.643501 | 1.85459 |
Example 4: Solve scalene triangle from valid side lengths
Inputs:
| d | e | f |
|---|---|---|
| 7 | 8 | 9 |
Excel formula:
=TRI_SSS(7, 8, 9)
Expected output:
| Result | ||
|---|---|---|
| 7 | 8 | 9 |
| 0.841069 | 1.01948 | 1.28104 |
Python Code
Show Code
from trianglesolver import sss as trianglesolver_sss
def tri_sss(d, e, f):
"""
Solve a triangle from three known side lengths.
See: https://pypi.org/project/trianglesolver/
This example function is provided as-is without any representation of accuracy.
Args:
d (float): First side length (length units).
e (float): Second side length (length units).
f (float): Third side length (length units).
Returns:
list[list]: A 2D array where the first row is [d, e, f] and the second row is [D, E, F].
"""
try:
result = trianglesolver_sss(d, e, f)
return [[result[0], result[1], result[2]], [result[3], result[4], result[5]]]
except Exception as e:
return f"Error: {str(e)}"Online Calculator