# Triangle solver (JavaScript)

## Program

Tips: In the triangle diagram, click on a letter to jump to that input. When solved, hover over a letter to read its value.

## 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.

In a valid solution, all side lengths are positive, and all angles are greater than 0° and less than 180°.

2 sides and an enclosed angle (SAS) always yields a unique solution.

2 angles and a side (ASA, AAS) always yields a unique solution, provided that the two given angles add up to less than 180°.

3 sides (SSS) yields a unique solution, or no solution if the longest side is longer than the sum of the other sides.

2 sides and a non-enclosed angle (SSA) yields 0, 1, or 2 solutions.

The source code is available for viewing.

## Download

A standalone offline version is available for download: triangle-solver.html (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.