Right Triangle Side & Angle Calculator
Use this calculator to find the missing sides and angles of a right-angled triangle. Enter any two known values (at least one must be a side), and the calculator will solve for the rest.
Results:
Side A:
Side B:
Hypotenuse:
Angle A:
Angle B:
.calculator-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
padding: 25px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
max-width: 700px;
margin: 30px auto;
border: 1px solid #e0e0e0;
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
font-size: 26px;
}
.calculator-container p {
color: #555;
line-height: 1.6;
margin-bottom: 15px;
}
.calculator-inputs .form-group {
margin-bottom: 15px;
display: flex;
flex-direction: column;
}
.calculator-inputs label {
margin-bottom: 7px;
color: #333;
font-weight: bold;
font-size: 15px;
}
.calculator-inputs input[type="number"] {
padding: 10px 12px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
width: 100%;
box-sizing: border-box;
transition: border-color 0.3s ease;
}
.calculator-inputs input[type="number"]:focus {
border-color: #007bff;
outline: none;
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
.calculate-button, .clear-button {
background-color: #007bff;
color: white;
padding: 12px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 17px;
font-weight: bold;
transition: background-color 0.3s ease, transform 0.2s ease;
width: auto;
margin-top: 10px;
margin-right: 10px;
}
.clear-button {
background-color: #6c757d;
}
.calculate-button:hover {
background-color: #0056b3;
transform: translateY(-1px);
}
.clear-button:hover {
background-color: #5a6268;
transform: translateY(-1px);
}
.calculator-results {
background-color: #e9f7ef;
border: 1px solid #d4edda;
border-radius: 8px;
padding: 20px;
margin-top: 25px;
}
.calculator-results h3 {
color: #28a745;
margin-top: 0;
margin-bottom: 15px;
font-size: 22px;
text-align: center;
}
.calculator-results p {
font-size: 16px;
color: #333;
margin-bottom: 8px;
}
.calculator-results p strong {
color: #000;
}
.error-message {
color: #dc3545;
background-color: #f8d7da;
border: 1px solid #f5c6cb;
padding: 10px;
border-radius: 5px;
margin-bottom: 15px;
text-align: center;
font-weight: bold;
}
@media (max-width: 600px) {
.calculator-container {
padding: 15px;
margin: 20px auto;
}
.calculator-container h2 {
font-size: 22px;
}
.calculate-button, .clear-button {
width: 100%;
margin-right: 0;
margin-bottom: 10px;
}
}
function toRadians(degrees) {
return degrees * (Math.PI / 180);
}
function toDegrees(radians) {
return radians * (180 / Math.PI);
}
function round(value, decimals) {
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
}
function clearForm() {
document.getElementById('inputSideA').value = ";
document.getElementById('inputSideB').value = ";
document.getElementById('inputHypotenuse').value = ";
document.getElementById('inputAngleA').value = ";
document.getElementById('inputAngleB').value = ";
document.getElementById('resultSideA').textContent = ";
document.getElementById('resultSideB').textContent = ";
document.getElementById('resultHypotenuse').textContent = ";
document.getElementById('resultAngleA').textContent = ";
document.getElementById('resultAngleB').textContent = ";
document.getElementById('errorMessage').textContent = ";
}
function calculateTriangle() {
var sideA = parseFloat(document.getElementById('inputSideA').value);
var sideB = parseFloat(document.getElementById('inputSideB').value);
var hypotenuse = parseFloat(document.getElementById('inputHypotenuse').value);
var angleA = parseFloat(document.getElementById('inputAngleA').value);
var angleB = parseFloat(document.getElementById('inputAngleB').value);
document.getElementById('errorMessage').textContent = ";
document.getElementById('resultSideA').textContent = ";
document.getElementById('resultSideB').textContent = ";
document.getElementById('resultHypotenuse').textContent = ";
document.getElementById('resultAngleA').textContent = ";
document.getElementById('resultAngleB').textContent = ";
var knownValues = 0;
if (!isNaN(sideA)) knownValues++;
if (!isNaN(sideB)) knownValues++;
if (!isNaN(hypotenuse)) knownValues++;
if (!isNaN(angleA)) knownValues++;
if (!isNaN(angleB)) knownValues++;
if (knownValues < 2) {
document.getElementById('errorMessage').textContent = 'Please enter at least two known values.';
return;
}
// Ensure at least one side is known
if (isNaN(sideA) && isNaN(sideB) && isNaN(hypotenuse)) {
document.getElementById('errorMessage').textContent = 'At least one side length must be provided.';
return;
}
// Validate input values
if ((!isNaN(sideA) && sideA <= 0) || (!isNaN(sideB) && sideB <= 0) || (!isNaN(hypotenuse) && hypotenuse <= 0)) {
document.getElementById('errorMessage').textContent = 'Side lengths must be positive numbers.';
return;
}
if ((!isNaN(angleA) && (angleA = 90)) || (!isNaN(angleB) && (angleB = 90))) {
document.getElementById('errorMessage').textContent = 'Acute angles must be between 0 and 90 degrees.';
return;
}
if (!isNaN(angleA) && !isNaN(angleB) && round(angleA + angleB, 5) !== 90) {
document.getElementById('errorMessage').textContent = 'Angles A and B must sum to 90 degrees for a right triangle.';
return;
}
// Convert known angles to radians for calculations
var angleARad = isNaN(angleA) ? NaN : toRadians(angleA);
var angleBRad = isNaN(angleB) ? NaN : toRadians(angleB);
// — Core Calculation Logic —
// Case 1: Two Legs (sideA, sideB) known
if (!isNaN(sideA) && !isNaN(sideB)) {
hypotenuse = Math.sqrt(sideA * sideA + sideB * sideB);
angleARad = Math.atan(sideA / sideB);
angleBRad = Math.atan(sideB / sideA);
}
// Case 2: One Leg and Hypotenuse (sideA, hypotenuse) known
else if (!isNaN(sideA) && !isNaN(hypotenuse)) {
if (sideA >= hypotenuse) {
document.getElementById('errorMessage').textContent = 'Side A cannot be greater than or equal to the hypotenuse.';
return;
}
sideB = Math.sqrt(hypotenuse * hypotenuse – sideA * sideA);
angleARad = Math.asin(sideA / hypotenuse);
angleBRad = Math.acos(sideA / hypotenuse);
}
// Case 3: One Leg and Hypotenuse (sideB, hypotenuse) known
else if (!isNaN(sideB) && !isNaN(hypotenuse)) {
if (sideB >= hypotenuse) {
document.getElementById('errorMessage').textContent = 'Side B cannot be greater than or equal to the hypotenuse.';
return;
}
sideA = Math.sqrt(hypotenuse * hypotenuse – sideB * sideB);
angleBRad = Math.asin(sideB / hypotenuse);
angleARad = Math.acos(sideB / hypotenuse);
}
// Case 4: One Leg and One Angle (sideA, angleA) known
else if (!isNaN(sideA) && !isNaN(angleA)) {
angleBRad = toRadians(90 – angleA);
hypotenuse = sideA / Math.sin(angleARad);
sideB = sideA / Math.tan(angleARad);
}
// Case 5: One Leg and One Angle (sideA, angleB) known
else if (!isNaN(sideA) && !isNaN(angleB)) {
angleARad = toRadians(90 – angleB);
hypotenuse = sideA / Math.cos(angleBRad);
sideB = sideA * Math.tan(angleBRad);
}
// Case 6: One Leg and One Angle (sideB, angleA) known
else if (!isNaN(sideB) && !isNaN(angleA)) {
angleBRad = toRadians(90 – angleA);
hypotenuse = sideB / Math.cos(angleARad);
sideA = sideB * Math.tan(angleARad);
}
// Case 7: One Leg and One Angle (sideB, angleB) known
else if (!isNaN(sideB) && !isNaN(angleB)) {
angleARad = toRadians(90 – angleB);
hypotenuse = sideB / Math.sin(angleBRad);
sideA = sideB / Math.tan(angleBRad);
}
// Case 8: Hypotenuse and One Angle (hypotenuse, angleA) known
else if (!isNaN(hypotenuse) && !isNaN(angleA)) {
angleBRad = toRadians(90 – angleA);
sideA = hypotenuse * Math.sin(angleARad);
sideB = hypotenuse * Math.cos(angleARad);
}
// Case 9: Hypotenuse and One Angle (hypotenuse, angleB) known
else if (!isNaN(hypotenuse) && !isNaN(angleB)) {
angleARad = toRadians(90 – angleB);
sideA = hypotenuse * Math.cos(angleBRad);
sideB = hypotenuse * Math.sin(angleBRad);
}
else {
document.getElementById('errorMessage').textContent = 'Insufficient information. Please provide at least two values, including at least one side.';
return;
}
// Convert angles back to degrees for display
angleA = toDegrees(angleARad);
angleB = toDegrees(angleBRad);
// Display results
document.getElementById('resultSideA').textContent = round(sideA, 4);
document.getElementById('resultSideB').textContent = round(sideB, 4);
document.getElementById('resultHypotenuse').textContent = round(hypotenuse, 4);
document.getElementById('resultAngleA').textContent = round(angleA, 4) + '°';
document.getElementById('resultAngleB').textContent = round(angleB, 4) + '°';
}
Understanding the Right Triangle Side & Angle Calculator
A right triangle is a special type of triangle that has one angle measuring exactly 90 degrees. This unique property makes it incredibly useful in various fields, from construction and engineering to navigation and art. The sides of a right triangle have specific names: the two sides forming the right angle are called legs (often denoted as 'Side A' and 'Side B'), and the side opposite the right angle is called the hypotenuse (often denoted as 'Side C').
Why Use This Calculator?
This calculator is designed to help you quickly find any missing side lengths or acute angles of a right triangle. Whether you're a student tackling geometry homework, a carpenter planning a roof, or an engineer designing a structure, knowing how to solve for missing triangle components is a fundamental skill. Instead of manually applying complex formulas, this tool streamlines the process, providing accurate results instantly.
Key Concepts Behind the Calculations
The calculator uses two fundamental mathematical principles to solve for missing values:
1. The Pythagorean Theorem
This theorem applies specifically to right triangles and states that the square of the length of the hypotenuse (c) is equal to the sum of the squares of the lengths of the two legs (a and b). Mathematically, it's expressed as:
a² + b² = c²
If you know any two sides of a right triangle, you can use this theorem to find the third side:
- To find the hypotenuse (c):
c = √(a² + b²)
- To find a leg (a):
a = √(c² - b²)
- To find a leg (b):
b = √(c² - a²)
2. Trigonometric Ratios (SOH CAH TOA)
Trigonometry provides relationships between the angles and sides of a right triangle. These ratios are defined relative to one of the acute angles (Angle A or Angle B):
- Sine (SOH):
sin(angle) = Opposite / Hypotenuse
- Cosine (CAH):
cos(angle) = Adjacent / Hypotenuse
- Tangent (TOA):
tan(angle) = Opposite / Adjacent
Where:
- Opposite: The side across from the angle.
- Adjacent: The side next to the angle (not the hypotenuse).
- Hypotenuse: The longest side, opposite the 90-degree angle.
These ratios, along with their inverse functions (arcsin, arccos, arctan), allow us to find missing angles when sides are known, or missing sides when an angle and a side are known.
How to Use the Calculator
- Identify Known Values: Look at your right triangle problem and determine which side lengths (Side A, Side B, Hypotenuse) or acute angles (Angle A, Angle B) you already know.
- Enter Values: Input your known values into the corresponding fields in the calculator. You must enter at least two values, and at least one of them must be a side length.
- Click "Calculate": Press the "Calculate Missing Values" button.
- View Results: The calculator will display all the missing side lengths and angles, rounded to four decimal places. If you entered contradictory information or insufficient data, an error message will appear.
- Clear: Use the "Clear" button to reset all fields and results for a new calculation.
Examples
Example 1: Finding the Hypotenuse (Pythagorean Theorem)
You have a right triangle with Leg A = 3 units and Leg B = 4 units. What is the length of the hypotenuse?
- Enter "3" into "Side A".
- Enter "4" into "Side B".
- Click "Calculate".
- Result: Hypotenuse = 5.0000, Angle A = 36.8699°, Angle B = 53.1301°
Example 2: Finding a Leg (Pythagorean Theorem)
A ladder (hypotenuse) is 10 feet long and leans against a wall. The base of the ladder is 6 feet from the wall (Leg B). How high up the wall does the ladder reach (Leg A)?
- Enter "10" into "Hypotenuse".
- Enter "6" into "Side B".
- Click "Calculate".
- Result: Side A = 8.0000, Angle A = 53.1301°, Angle B = 36.8699°
Example 3: Finding Sides with an Angle (Trigonometry)
You have a ramp that makes a 30-degree angle with the ground (Angle A). The length of the ramp (hypotenuse) is 15 feet. How high is the ramp (Side A) and how far does it extend horizontally (Side B)?
- Enter "15" into "Hypotenuse".
- Enter "30" into "Angle A".
- Click "Calculate".
- Result: Side A = 7.5000, Side B = 12.9904, Angle B = 60.0000°
Limitations
This calculator is specifically designed for right-angled triangles. It cannot be used to solve for missing sides or angles in other types of triangles (e.g., acute or obtuse triangles) which require the Law of Sines or Law of Cosines.