Triangle solver (JavaScript)
Program
Description
This JavaScript program calculates the missing sides and angles of a triangle. Give exactly 3 pieces of information, including at least one side.
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.
3 sides (SSS) yields a unique solution, or no solution if the longest side is longer than the sum of the other sides.
2 angles and a side (ASA) always yields a unique solution.
2 sides and an enclosed angle (SAS) always yields a unique solution.
2 sides and a non-enclosed angle (SSA) yields 0, 1, or 2 solutions.
The source code is available.