Triangle Calculator
Solve triangles: sides, angles, area (Heron's formula), perimeter, and type detection.
About the Triangle Calculator
The triangle calculator solves for the missing side, the missing angle, the perimeter, and the area of a triangle given two sides and either the third side (SSS) or the included angle (SAS). Both modes use Heron's formula and the law of cosines, the two classical tools of triangle geometry.
Heron's formula, attributed to Heron of Alexandria circa 60 CE, computes the area from the three side lengths alone, without any angles: A = sqrt(s(s-a)(s-b)(s-c)) where s = (a+b+c)/2 is the semi-perimeter. The formula was also known earlier to Archimedes, per Al-Biruni's 11th-century commentary. The law of cosines c^2 = a^2 + b^2 - 2ab*cos(C) generalises the Pythagorean theorem to non-right triangles and lets us convert between side lengths and angles.
The tool enforces the triangle inequality (the sum of any two sides must exceed the third) before computing, and classifies the triangle by both sides (equilateral, isosceles, scalene) and angles (acute, right, obtuse). A right triangle is one where the largest side squared equals the sum of the other two sides squared, by the Pythagorean theorem (Euclid Elements Book I Proposition 47).
All inputs are validated. Negative or zero side lengths are rejected, as are angles outside the open interval (0, 180) degrees. The SSS mode checks the triangle inequality explicitly before running Heron's formula.
How It Works
The two modes use different combinations of the same formulas. For SSS (three sides known), the area is computed directly from Heron's formula:
s = (a + b + c) / 2 (semi-perimeter)
A = sqrt(s * (s-a) * (s-b) * (s-c))
The missing angle C is computed from the law of cosines rearranged:
cos(C) = (a^2 + b^2 - c^2) / (2ab)
C = acos((a^2 + b^2 - c^2) / (2ab)) (in radians)
For SAS (two sides and the included angle known), the missing side c is computed from the law of cosines directly:
c = sqrt(a^2 + b^2 - 2ab * cos(C))
Once all three sides are known, Heron's formula gives the area. The perimeter is simply the sum of the three sides.
Triangle classification is then performed: by sides (equilateral if all three equal, isosceles if any two equal, scalene otherwise) and by angles (right if the largest side squared equals the sum of the other two squared, obtuse if greater, acute otherwise). The right-triangle test is the Pythagorean theorem applied to the largest side.
The triangle inequality (a + b > c, a + c > b, b + c > a) is enforced before any computation, since otherwise the side lengths do not form a valid triangle and Heron's formula would return NaN due to taking the square root of a negative number.
Worked Examples
Using the default SSS values a = 3, b = 4, c = 5, the triangle inequality is satisfied (3 + 4 > 5, 3 + 5 > 4, 4 + 5 > 3). The semi-perimeter is s = 6. Heron's formula gives A = sqrt(6 * 3 * 2 * 1) = sqrt(36) = 6. The angle C is acos((9 + 16 - 25) / 24) = acos(0) = 90 degrees. This is the classic 3-4-5 right triangle, one of the Pythagorean triples known to the Babylonians (Plimpton 322 tablet, circa 1800 BCE).
For an equilateral triangle with a = b = c = 6, the area is sqrt(9 * 3 * 3 * 3) = sqrt(243) = 15.5885, and each angle is 60 degrees. The tool classifies this as equilateral and acute.
For an SAS example with a = 5, b = 7, and included angle C = 60 degrees, the missing side c is sqrt(25 + 49 - 70 * 0.5) = sqrt(39) = 6.2450. The semi-perimeter is (5 + 7 + 6.2450) / 2 = 9.1225, and the area is sqrt(9.1225 * 4.1225 * 2.1225 * 2.8775) = sqrt(228.83) = 15.1327. This triangle is scalene and acute.
When to Use This Tool
Use the triangle calculator when you need to:
- Compute the area of a triangular plot of land given the side lengths.
- Solve for an unknown side or angle in a trigonometry problem.
- Verify a hand-drawn solution to a triangle geometry exercise.
- Compute the area of a triangular sail, flag, or piece of fabric from measurements.
- Classify a triangle by sides and angles in a geometry lesson.
- Determine the third side of a triangle given two sides and the included angle (SAS).
- Check whether three given lengths can form a valid triangle (triangle inequality).
Limitations & Disclaimer
This calculator handles SSS and SAS triangles only. The ambiguous SSA case and AAA (which does not determine side lengths) are not supported. The triangle inequality is enforced; invalid inputs are rejected. Angle classification uses a tolerance of 1e-9 to detect right triangles, which may misclassify borderline cases. Results are subject to IEEE 754 floating-point precision. See our disclaimer for full details.
Frequently Asked Questions
What is Heron's formula and when was it discovered?
Heron's formula computes the area of a triangle from its three side lengths alone: A = sqrt(s(s-a)(s-b)(s-c)) where s is the semi-perimeter. It is attributed to Heron of Alexandria circa 60 CE, but was known earlier to Archimedes per Al-Biruni's commentary. The formula is notable because it does not require any angles or heights.
What is the law of cosines?
The law of cosines generalises the Pythagorean theorem to non-right triangles: c^2 = a^2 + b^2 - 2ab * cos(C). When C is 90 degrees, cos(C) is 0 and the law reduces to c^2 = a^2 + b^2, the Pythagorean theorem. The law is used to compute a side from two sides and the included angle (SAS) or an angle from three sides (SSS).
What is the triangle inequality?
The triangle inequality states that the sum of any two sides of a triangle must be strictly greater than the third side. For sides a, b, c, all three inequalities must hold: a + b > c, a + c > b, b + c > a. The tool checks all three before computing, since otherwise the side lengths do not form a valid triangle.
How does the calculator classify triangles?
By sides: equilateral if all three are equal, isosceles if any two are equal, scalene otherwise. By angles: right if the largest side squared equals the sum of the other two squared (the Pythagorean test), obtuse if greater, acute otherwise. The largest side is used for the angle classification because it sits opposite the largest angle.
What is a Pythagorean triple?
A set of three positive integers (a, b, c) satisfying a^2 + b^2 = c^2, such as (3, 4, 5) or (5, 12, 13). The Babylonians tabulated such triples on the Plimpton 322 clay tablet around 1800 BCE. The triangle calculator correctly identifies a 3-4-5 triangle as a right triangle via the Pythagorean test.
Why does the SAS mode require the included angle?
Because the law of cosines requires the angle between the two known sides. If you know two sides and a non-included angle, the problem is the ambiguous SSA case, which can have zero, one, or two solutions and requires a more complex algorithm. The tool restricts input to SSS and SAS for clarity and unambiguous solutions.
Last updated: September 9, 2026 · Author: HT99 Tools Editorial Team