Right Triangle Calculator

Enter any two values — two sides, or a side and an angle — to solve the rest, with area, perimeter, and a live diagram.

b a c A B

Known values (enter any 2)

°
°

Enter any two values (at least one must be a side).

Leg a
Leg b
Hypotenuse c
Angle A
Angle B
Area
Perimeter
Altitude to c
Length output unit
Precision

Worked examples

Two legs (3-4-5)

Diagonal brace across a rectangular frame

A framer knows the two sides of a rectangular opening and needs the length of the diagonal brace that fits corner to corner.

a
3 ft
b
4 ft

Diagonal c = 5 ft, angles 36.87° & 53.13°

Side + angle

Rafter length from roof rise and pitch

A roofer knows the vertical rise on one side and the pitch angle, and needs the rafter (hypotenuse) length to cut.

a (rise)
5 m
A (pitch)
30°

Rafter c = 10 m, run b = 8.66 m

How the formulas work

A right triangle is fixed by any two facts beyond its 90° corner, and which two you have decides which relationship solves it. When you know both legs, the Pythagorean theorem gives the hypotenuse and the arctangent gives the angles:

c = √(a² + b²) · A = atan(a / b) · B = 90° − A

When you know one side and one acute angle, the basic trig ratios take over — sine ties a leg to the hypotenuse and the opposite angle, cosine ties it to the adjacent angle, and tangent ties the two legs:

a = c · sin(A) · b = c · cos(A) · a = b · tan(A)

From the three sides everything else follows directly: the area is a half-base-times-height with the two legs as base and height, the perimeter is their sum with the hypotenuse, and the altitude dropped to the hypotenuse is the product of the legs over the hypotenuse. The right angle C stays fixed at 90° throughout, which is exactly why only two extra values — not three — are ever needed.

Area = ½ · a · b · Perimeter = a + b + c · h꜀ = a · b / c
b a c h꜀ A B C

Frequently asked questions

How many values do I need to enter to solve a right triangle?

Exactly two, as long as at least one of them is a side. Because the right angle is already known (C = 90°), two more facts pin the whole triangle down: two sides, or one side plus one of the acute angles. Two angles alone aren't enough — the shape would be fixed but its size wouldn't, so you'd have infinitely many triangles. The calculator watches your inputs and solves the moment it has a valid pair.

Which side is the hypotenuse, and which are the legs?

The hypotenuse (c here) is always the longest side — the one directly across from the 90° corner. The other two sides, the legs (a and b), are the ones that actually form the right angle. In this calculator angle A sits opposite leg a and angle B opposite leg b, so if you know a side and the angle across from it, you know a matched pair the trig functions can work with directly.

When do I use the Pythagorean theorem versus sine and cosine?

Use the Pythagorean theorem — a² + b² = c² — whenever your two known values are both sides, since it relates the three sides with no angles involved. Reach for sine, cosine, and tangent when an angle is one of your knowns: for example, a = c·sin(A) or b = a/tan(A). This calculator picks the right relationship automatically based on which two fields you filled in, but the formula section below shows every case so you can follow the working by hand.

What is the "altitude to the hypotenuse" in the results?

It's the perpendicular distance from the right-angle corner straight down to the hypotenuse — the height of the triangle if you rest it on its longest side. It equals (a·b)/c, and it comes up constantly in construction and drafting: it's the clearance under a diagonal brace, the depth of a triangular notch, or the rise of a roof valley measured square to its run. It also splits the triangle into two smaller triangles that are each similar to the original.

Can I use this for roof pitch, stair stringers, or a diagonal brace?

Yes — those are all right-triangle problems in disguise. A roof's rise and run are the two legs and the rafter length is the hypotenuse; a stair's total rise and total run give you the stringer length and the pitch angle; a diagonal brace across a rectangular frame is the hypotenuse of the two frame sides. Enter the two measurements you have (say rise and run, or run and pitch angle) and the calculator returns the diagonal length and the angle you'd cut.

Do the sides have to be in the same unit?

Each length field has its own unit picker, and the calculator converts everything to a common base before solving, so you can mix units freely — enter one leg in feet and another in inches and the result still comes out right. The output sides are shown in the unit you pick for them, and the Imperial / Metric switch flips every length field at once while preserving the physical measurement, not just relabeling the number.