Right Triangle Calculator

A right triangle is fully determined by any two of its parts other than the two acute angles, and this calculator solves it from whichever pair you have: two legs, a leg and the hypotenuse, or one side with one acute angle. It returns all three sides, both acute angles, the area, the perimeter and the altitude to the hypotenuse, and shows the SOHCAHTOA ratio it used at each step. Angles are in degrees; lengths use any unit you like and come back in it.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
What you knowAngle A is always the one opposite leg a and adjacent to leg b.Both legs (a and b)
Leg a (opposite angle A)The vertical side in a rise-and-run picture: the rise.3
Leg b (adjacent to angle A)The horizontal side in a rise-and-run picture: the run.4
Hypotenuse cThe side opposite the right angle, always the longest.5
Angle AThe acute angle opposite leg a, strictly between 0° and 90°.36.869898 °

It returns

  • Hypotenuse c — Opposite the right angle, always the longest side.
  • Leg a (opposite A)
  • Leg b (adjacent to A)
  • Angle A
  • Angle B — Always 90° minus angle A, because the three angles total 180°.
  • Area
  • Perimeter
  • Altitude to the hypotenuse — The perpendicular from the right angle down to the hypotenuse, equal to a·b ÷ c.

The formula

sinA=ac,cosA=bc,tanA=ab
h=abc

In plain text: sin A = a/c, cos A = b/c, tan A = a/b; a² + b² = c²; B = 90° − A

  • aLeg opposite angle A (units)
  • bLeg adjacent to angle A (units)
  • cHypotenuse, opposite the right angle (units)
  • A, BThe two acute angles, which always sum to 90° (degrees)

SOHCAHTOA is the mnemonic: Sine = Opposite/Hypotenuse, Cosine = Adjacent/Hypotenuse, Tangent = Opposite/Adjacent. Opposite and adjacent are relative to the angle you name.

Updated Category Triangle Solvers & Trigonometric Laws Verified against published test cases Reading time 9 min

Two parts solve a right triangle

A general triangle needs three pieces of information to pin down. A right triangle needs only two, because the 90° angle is one piece you already have. Give it any two parts — excluding the useless pairing of the two acute angles, which fixes the shape but not the size — and every other side, angle and area follows.

Which formula you use depends on whether your two parts are two sides or a side and an angle. Two sides means Pythagoras plus one inverse trig function. A side and an angle means one direct trig function for each remaining side. The names opposite, adjacent and hypotenuse are all relative to the angle you are working from: the hypotenuse never changes, but which leg is opposite and which is adjacent swaps when you switch from angle A to angle B.

This is the geometry behind roof pitch, stair rise and run, ramp slope, ladder angle, guy-wire length, cable sag layout, machining a chamfer and reading a grade. In all of them one leg is a rise, the other is a run, the hypotenuse is the sloping member, and the angle is what a protractor or an inclinometer reads. For the sides alone without any angles, the Pythagorean theorem calculator is the leaner tool.

SOHCAHTOA, and picking the ratio that avoids extra steps

The three ratios are defined against a chosen acute angle. SOH: sin A = opposite / hypotenuse. CAH: cos A = adjacent / hypotenuse. TOA: tan A = opposite / adjacent. Every right-triangle problem is one of these rearranged, and the skill is choosing the ratio that connects what you have to what you want in a single step.

If you know a leg and want the hypotenuse, use the ratio that contains both: sine if your leg is opposite the angle, cosine if it is adjacent. If you know both legs and want the angle, use tangent, because it is the only ratio built from two legs. If you know a leg and the hypotenuse and want the angle, use sine or cosine depending on which leg you have. Going into the trig functions computes a side; the inverse functions — arcsin, arccos, arctan — come back out to an angle.

Three facts finish the triangle regardless of route. The acute angles are complementary, A + B = 90°, so one gives the other immediately. The area is ½ab, because the two legs are already perpendicular and each serves as the other's height. And the altitude to the hypotenuse is h = ab/c, which comes from equating the two ways of writing the area, ½ab = ½ch.

The altitude is worth more attention than it usually gets. It splits the triangle into two smaller triangles, each similar to the original and to each other, which gives the geometric mean relations h² = pq, a² = cp and b² = cq, where p and q are the two hypotenuse segments. The inradius has an unusually simple form here too: r = (a + b − c)/2, so the 3-4-5 triangle has an inscribed circle of radius exactly 1.

Worked example: a roof rafter and a wheelchair ramp

Part one: a 4-in-12 roof. The roof rises 4 units for every 12 of horizontal run. Take a run of 12.000 ft.

  1. Pitch angle. tan A = rise/run = 4/12 = 0.333333, so A = arctan 0.333333 = 18.4349°.
  2. Rafter length. c = √(4² + 12²) = √160 = 12.6491 ft. Equivalently c = 12 / cos 18.4349° = 12 / 0.948683 = 12.6491 ft.
  3. Rafter per foot of run. 12.6491/12 = 1.05409, the standard length multiplier for a 4-in-12 pitch.
  4. Other angle. B = 90 − 18.4349 = 71.5651°, the angle at the ridge.
  5. Gable area. ½ × 4 × 12 = 24 ft² for the triangle under one slope.

Part two: a ramp. A landing sits 30.000 in above grade and the ramp must not exceed a 1:12 slope.

  1. Required run. At 1:12, run = 12 × rise = 12 × 30 = 360 in, that is 30 ft.
  2. Ramp angle. arctan(30/360) = arctan 0.083333 = 4.7636°.
  3. Sloping length. c = √(30² + 360²) = √130500 = 361.2478 in, or 30.104 ft — only 0.35% longer than the run, which is why shallow slopes let you treat run and slope length as interchangeable for rough estimating but not for ordering material.
  4. Altitude to the hypotenuse. ab/c = (30 × 360)/361.2478 = 29.8963 in, the perpendicular clearance from the ramp surface to the top-of-landing corner.

Note the contrast between the two: at 18.43° the sloping member is 5.4% longer than the run, while at 4.76° it is only 0.35% longer. The excess grows with the square of the slope for small angles, since 1/cos A ≈ 1 + A²/2 in radians.

Reading the angle, the slope and the precision

Trades quote the same information three ways and they are all the tangent. Pitch is rise per 12 of run (4-in-12). Slope ratio is run per unit rise (1:12) or its reciprocal. Grade is rise divided by run as a percentage. A 4-in-12 roof is a 33.3% grade and an 18.4349° angle; a 1:12 ramp is 8.33% and 4.7636°. Only at 45° do grade and slope ratio coincide at 100% and 1:1.

Watch where precision goes. Recovering an angle from two legs is well behaved across the whole range, but recovering a leg from an angle is not: near 90° the tangent explodes, so a tenth of a degree of angle error near 89° moves the opposite leg enormously. Near 0° the reverse problem appears — the hypotenuse and the adjacent leg become almost identical, which makes it hard to tell them apart from measurement, and the calculator warns below 1°.

Sanity-check every result three ways. The hypotenuse must exceed both legs but be less than their sum. The larger leg must face the larger angle. And the two acute angles must add to 90°. Those three checks catch nearly every misidentified side.

One more relationship worth carrying: the ratio of the hypotenuse to the run is 1/cos A, which is the multiplier that converts a plan dimension into a sloping one. It is 1.0541 at 4-in-12, 1.1180 at 6-in-12, 1.4142 at 12-in-12. Roofing material is estimated on the sloped area, so plan area times that multiplier is the quantity to order.

Common slopes as angles, grades and length multipliers

Angle = arctan(rise/run); multiplier = sloping length ÷ run = 1/cos(angle) = √(1 + (rise/run)²).
Rise : runGradeAngleLength multiplier
1 : 128.33%4.7636°1.00347
2 : 1216.67%9.4623°1.01379
3 : 1225.00%14.0362°1.03078
4 : 1233.33%18.4349°1.05409
6 : 1250.00%26.5651°1.11803
8 : 1266.67%33.6901°1.20185
12 : 12100.00%45.0000°1.41421
16 : 12133.33%53.1301°1.66667

The multiplier converts a horizontal plan length or plan area into the sloped length or area — the figure to order roofing by. Note that grade and angle are not proportional: doubling the grade from 50% to 100% moves the angle only from 26.57° to 45°.

Mistakes that solve the wrong triangle

  • Swapping opposite and adjacent. They are defined relative to the angle you name, so they trade places between angle A and angle B. Label the triangle before choosing a ratio.
  • Using the hypotenuse as a leg in the area. Area is ½ab with the two legs, because only they are perpendicular to each other. Using c gives a number far too large.
  • Leaving the calculator in radian mode. tan(30) is 0.5774 in degrees and −6.4053 in radians. The sign flip usually gives it away, but not always.
  • Confusing grade with angle. A 100% grade is 45°, not 90°. Grade is the tangent expressed as a percentage, and it has no upper bound while the angle stops at 90°.
  • Entering an angle of 90° or more as an acute angle. The right angle is already fixed; both remaining angles must be strictly under 90°.
  • Measuring the rafter along the plan rather than the slope. Multiply the run by 1/cos A, or order by the sloped figure this calculator reports.

Beyond the right angle

Two right triangles are worth memorising rather than computing, because their ratios are exact. The 30-60-90 triangle has sides in the ratio 1 : √3 : 2, and the 45-45-90 triangle has 1 : 1 : √2. Between them they generate the exact sine and cosine values for 30°, 45° and 60° that appear throughout trigonometry.

When the triangle has no right angle, none of SOHCAHTOA applies directly. Use the law of sines calculator when you have a matched side-and-opposite-angle pair, and the law of cosines calculator for two sides with the included angle or for three sides. A standard technique is to drop an altitude and turn the oblique triangle into two right ones, which is how both of those laws are proved.

The ratios here also define the trigonometric functions themselves, which then extend far past triangles into circular and periodic behaviour. The sin cos tan calculator evaluates them at any angle, and the inverse trig functions calculator runs the reverse. If your triangle arrives as coordinates rather than measurements, get the leg lengths from the distance formula calculator or read the angle straight off the gradient with the slope of a line calculator, since slope and tangent are the same quantity.

Frequently asked questions

What does SOHCAHTOA stand for?

Sine = Opposite ÷ Hypotenuse, Cosine = Adjacent ÷ Hypotenuse, Tangent = Opposite ÷ Adjacent. Opposite and adjacent are named relative to the angle you are working from, so they swap when you move to the other acute angle. The hypotenuse is always the side facing the right angle.

How many parts do I need to solve a right triangle?

Two, as long as at least one is a side. The right angle counts as one of the three pieces a general triangle needs. Two acute angles are not enough, because they fix only the shape — every scaled copy has the same angles.

How do I find an angle from the rise and run?

Take the inverse tangent of rise divided by run. A 4-in-12 roof gives arctan(4/12) = arctan 0.3333 = 18.4349°. That is the same calculation as converting a slope or a gradient into an angle, which is why slope and tangent are interchangeable terms.

What is the altitude to the hypotenuse used for?

It is the perpendicular distance from the right-angle vertex to the hypotenuse, h = ab/c, and it is the clearance figure when something has to pass under a diagonal member. It also splits the triangle into two smaller triangles similar to the original, which gives the geometric mean relations h² = pq and a² = cp.

Is a 100% grade the same as a 45-degree slope?

Yes. Grade is rise divided by run expressed as a percentage, so 100% means the rise equals the run, which is exactly 45°. Grades can exceed 100% — a 16-in-12 roof is 133% — while the angle can never reach 90°.

Why does my answer change when I switch which leg I call opposite?

Because the ratios are defined against a specific angle. Calling leg a opposite means you are working from angle A; the same triangle viewed from angle B swaps opposite and adjacent, so sine becomes cosine and the tangent becomes its reciprocal. The triangle is unchanged; only the labelling moved.

How much longer is a rafter than the run it covers?

By the factor 1/cos A, which this calculator reports through the hypotenuse. It is 1.0541 for 4-in-12, 1.1180 for 6-in-12 and 1.4142 for 12-in-12. Multiply plan area by the same factor to get the sloped area for material ordering.

What is the inradius of a right triangle?

r = (a + b − c)/2, the radius of the largest circle that fits inside. For a 3-4-5 triangle that is (3 + 4 − 5)/2 = 1 exactly. The formula is far simpler than the general triangle case because the right angle lets two of the tangent lengths collapse together.

References

  • CRC Standard Mathematical Tables and Formulae, 33rd ed. — CRC Press
  • Euclid's Elements, Book VI, Proposition 8 (the altitude and the geometric mean relations) — Public domain
  • Trigonometry, 11th ed. — Lial, Hornsby, Schneider and Daniels, Pearson