Triangle solver (JavaScript)
Program
Description
When you give exactly three pieces of information, including at least one side, this JavaScript program calculates the missing sides and angles of a triangle.
Math notes:
All sides are measured in the same unit. For example, you cannot directly solve a triangle with the sides 3 metres, 5 feet, and 2 yards; you must convert the side lengths to a common unit first.
In a valid solution, all side lengths are positive, and all angles are greater than 0° and less than 180°.
Two sides and one enclosed angle (SAS) always yields one unique solution.
Two angles and one side (ASA, AAS) yields one unique solution, provided that the two given angles add up to less than 180°.
Three sides (SSS) yields one unique solution, provided that the longest side is longer than the sum of the other sides.
Two sides and one non-enclosed angle (SSA) yields zero, one, or two solutions.
Miscellaneous notes:
In the triangle diagram, click on a letter to jump to that input. When solved, hover over a letter to read its value.
The source TypeScript code and compiled JavaScript code are available for viewing.
Download
A standalone offline version is available for download: triangle-solver.xhtml (right-click the link to save)
This file is free for personal use. For teachers or commercial use, please contact me to buy a registration for $10 USD.