Triangle Calculator: Solve Any Triangle from Sides and Angles
By FindMySum · Last reviewed
A triangle calculator finds the sides, angles, area and perimeter of a triangle you only partly know. Three measurements are enough to fix a flat triangle completely, as long as at least one of them is a side: two sides of a right triangle, all three sides, two sides and the angle between them, or two angles and a side. From those, the Pythagorean theorem, the law of cosines and the law of sines recover everything else. This article explains which formula handles which case and why, works through the calculator's default 3-4-5 triangle and a general example, and covers the cases that need care.
Labelling the triangle
The calculator uses the standard convention: the sides are a, b and c, and each angle takes the capital letter of the side opposite it, so angle A faces side a. In a right triangle, C is the right angle and c is the hypotenuse, the longest side. Getting the labels right is half the job: the formulas below only work if each angle is paired with the side across from it.
Which formula for which case
| You know | Method | Main formula |
|---|---|---|
| Two sides of a right triangle | Pythagorean | a² + b² = c² |
| Three sides (SSS) | Law of cosines for the angles | cos A = (b² + c² − a²) ÷ 2bc |
| Two sides and the angle between them (SAS) | Law of cosines for the third side | c² = a² + b² − 2ab cos C |
| Two angles and the side between them (ASA) | Angle sum, then law of sines | a ÷ sin A = c ÷ sin C |
| Two angles and another side (AAS) | Angle sum, then law of sines | b = a × sin B ÷ sin A |
The law of cosines is the Pythagorean theorem with a correction term. When C is 90°, cos C is 0 and the correction disappears. When C is less than 90°, the third side is shorter than the right-angle case would give; when C is more than 90°, cos C is negative and the side is longer.
The law of sines says each side is proportional to the sine of its opposite angle. It is the natural tool once you know two angles, because the third angle is simply 180° minus the other two.
Area
For a right triangle, the area is half the product of the legs, area = ½ab. For any other triangle, the calculator uses Heron's formula, which needs only the three sides: with the semiperimeter s = (a + b + c) ÷ 2, the area is √(s(s − a)(s − b)(s − c)). Written that way, Heron's formula loses accuracy for long, thin triangles, because subtracting nearly equal numbers wipes out significant digits. The calculator uses the rearranged form published by William Kahan of the University of California, Berkeley, which sorts the sides first and stays accurate even for needle-shaped triangles.
Worked example: the calculator's defaults
The calculator opens in Pythagorean mode, solving for the hypotenuse c with legs a = 3 and b = 4.
- Hypotenuse. c² = 3² + 4² = 9 + 16 = 25, so c = 5.
- Angle A. The tangent of A is the opposite side over the adjacent side, 3 ÷ 4 = 0.75, so A = 36.86989765°.
- Angle B. The two acute angles of a right triangle add to 90°, so B = 90° − 36.86989765° = 53.13010235°, and C = 90°.
- Area. ½ × 3 × 4 = 6 square units.
- Perimeter. 3 + 4 + 5 = 12 units.
The calculator classifies it as a right, scalene triangle (no two sides equal). The angles are not round numbers even though the sides are whole, which is typical: whole-number sides and whole-number angles rarely go together.
A general triangle from three sides
Switch to SSS and enter sides of 7, 8 and 9.
- Angle A from the law of cosines: cos A = (8² + 9² − 7²) ÷ (2 × 8 × 9) = 96 ÷ 144 = 0.667, giving A = 48.1896851°.
- Angle B the same way: cos B = (7² + 9² − 8²) ÷ (2 × 7 × 9) = 66 ÷ 126, giving B = 58.41186449°.
- Angle C = 180° − A − B = 73.3984504°. All three are under 90°, so the triangle is acute.
- Area by Heron: s = 24 ÷ 2 = 12, and √(12 × 5 × 4 × 3) = √720 = 26.83281573 square units.
- Perimeter = 24 units.
As a check, the largest angle sits opposite the longest side, 9, and the smallest opposite the shortest, 7. That ordering always holds, and it is a quick way to catch a mislabelled input.
Two angles and a side
In AAS mode with a = 10, A = 40° and B = 60°, the third angle is C = 80°. The law of sines gives b = 13.47296355 and c = 15.32088886, and the area is 66.34139482 square units.
From coordinates: the shoelace formula
When you know where the corners are rather than how long the sides are, for example from a map grid or a graph, choose "Coordinates of the three corners" and enter A(x1, y1), B(x2, y2) and C(x3, y3). The area comes straight from the shoelace formula, Area = |x1(y2 − y3) + x2(y3 − y1) + x3(y1 − y2)| / 2, named for the criss-cross pattern of products when the coordinates are written in two columns. For corners (1, 1), (5, 2) and (3, 6) the sum is 1 × (2 − 6) + 5 × (6 − 1) + 3 × (1 − 2) = −4 + 25 − 3 = 18, so the area is 9 square units.
The side lengths then follow from the distance formula (a = |BC| = √20 ≈ 4.4721, b = |CA| = √29 ≈ 5.3852, c = |AB| = √17 ≈ 4.1231) and the angles from the law of cosines, exactly as in the SSS case: about 54.16°, 77.47° and 48.37°. If the sum is zero the three points lie on one line and there is no triangle.
Cases that need care
Rounding in the displayed angles. The calculator works to 10 significant digits, but if you copy rounded angles into another tool, their sum may come out at 179.99° or 180.01°. Use the unrounded values for any follow-on calculation.
Measured inputs carry error. If the sides come from a tape measure, the computed angles are only as good as the measurements. Small errors in the sides of a very flat triangle can move the largest angle a lot.
Flat geometry only. The formulas assume a plane. Over short distances that is fine for floors, roofs, ramps and survey sketches, but triangles drawn on the earth's surface over long distances need spherical trigonometry, which the calculator doesn't do.
SSA is excluded. Two sides and an angle that isn't between them can give two valid triangles, so the calculator leaves that case to you.
Using the result
For roof pitch, stair stringers and ramps, the Pythagorean mode gives the sloped length from the rise and run; the area and volume calculator handles triangles alongside other shapes, and the square footage calculator totals the rectangular rooms you add a triangular gable or bump-out to. To scale a triangle up or down while keeping its shape, multiply every side by the same factor with the ratio and proportion calculator: the angles stay the same and the area changes by the square of the factor. When a project depends on the result, measure twice and check that the computed diagonal matches the one you can measure.
More questions
Why can't I enter two sides and an angle that isn't between them?
That combination, called SSA, is the ambiguous case. Depending on the numbers, two sides and a non-included angle can fit no triangle, exactly one, or two different triangles, one with an acute angle and one with an obtuse angle in the same place. Rather than guess which one you mean, the calculator leaves SSA out. If you know whether the unknown angle is acute or obtuse, find it with the law of sines and then use SAS.
How do builders use the 3-4-5 rule to check a square corner?
They rely on the converse of the Pythagorean theorem: if the sides of a triangle satisfy a² + b² = c², the angle opposite c is exactly 90°. Measure 3 units along one wall and 4 along the other; if the diagonal between the marks is exactly 5, the corner is square. Multiples such as 6-8-10 or 9-12-15 (in feet or metres) give better accuracy on large layouts like decks and foundations.
What units are the area and perimeter in?
Whatever unit you used for the sides. If you enter sides in metres, the perimeter is in metres and the area in square metres; in inches, the area is in square inches. Angles are always in degrees. Don't mix units: convert every side to the same unit before entering them, or the results will be meaningless.
Why does SSS mode reject some sets of side lengths?
Three lengths only form a triangle if each is shorter than the other two added together, a rule called the triangle inequality. Sides of 2, 3 and 6 fail because 2 + 3 is less than 6: the two short sides can't reach each other. Sides of 2, 3 and 5 also fail, because they would lie flat in a straight line with zero area.
How do I find the height of a triangle from the results?
Rearrange the area formula. Since area = ½ × base × height, the height to any side is twice the area divided by that side. For the 3-4-5 default, the height to the hypotenuse is 2 × 6 ÷ 5 = 2.4 units. You can pick any side as the base; each has its own height, and all three give the same area.
What is a Pythagorean triple?
A set of three whole numbers that satisfy a² + b² = c², so they are the sides of a right triangle with no decimals. The best known are 3-4-5, 5-12-13, 8-15-17 and 7-24-25. Any multiple of a triple is also a triple, which is why 6-8-10 works. The calculator returns whole-number sides for these and a decimal hypotenuse for most other pairs of legs.
Does the order of the corners matter for the shoelace formula?
Only for the sign. Going around the triangle counter-clockwise gives a positive sum and clockwise a negative one; the area is the absolute value halved either way, and the calculator reports which way you went.
Sources
- Algebra and Trigonometry 2e, chapter on further applications of trigonometry: non-right triangles, law of sines and law of cosines, OpenStax (Rice University)
- Precalculus 2e, right triangle trigonometry and non-right triangles, OpenStax (Rice University)
- W. Kahan, Miscalculating Area and Angles of a Needle-like Triangle, University of California, Berkeley
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.