function updateSideOptions() {
var triangleType = document.getElementById("triangleType").value;
var sideType = document.getElementById("sideType");
sideType.innerHTML = "";
if (triangleType === "45-45-90") {
var opt1 = document.createElement("option");
opt1.value = "leg";
opt1.text = "Leg (a or b)";
var opt2 = document.createElement("option");
opt2.value = "hypotenuse";
opt2.text = "Hypotenuse (c)";
sideType.add(opt1);
sideType.add(opt2);
} else {
var opt1 = document.createElement("option");
opt1.value = "shortLeg";
opt1.text = "Short Leg (a – opposite 30°)";
var opt2 = document.createElement("option");
opt2.value = "longLeg";
opt2.text = "Long Leg (b – opposite 60°)";
var opt3 = document.createElement("option");
opt3.value = "hypotenuse";
opt3.text = "Hypotenuse (c – opposite 90°)";
sideType.add(opt1);
sideType.add(opt2);
sideType.add(opt3);
}
}
function calculateSpecialTriangle() {
var type = document.getElementById("triangleType").value;
var side = document.getElementById("sideType").value;
var val = parseFloat(document.getElementById("sideValue").value);
var resultDiv = document.getElementById("triangleResult");
var resultContent = document.getElementById("resultContent");
if (isNaN(val) || val <= 0) {
alert("Please enter a valid positive number for the side length.");
return;
}
var resHTML = "";
var legA, legB, hypotenuse;
if (type === "45-45-90") {
if (side === "leg") {
legA = val;
legB = val;
hypotenuse = val * Math.sqrt(2);
} else {
hypotenuse = val;
legA = val / Math.sqrt(2);
legB = legA;
}
resHTML = "Leg (a): " + legA.toFixed(4) + "" +
"Leg (b): " + legB.toFixed(4) + "" +
"Hypotenuse (c): " + hypotenuse.toFixed(4) + "" +
"Ratio used: 1 : 1 : √2";
} else {
// 30-60-90
if (side === "shortLeg") {
legA = val;
legB = val * Math.sqrt(3);
hypotenuse = val * 2;
} else if (side === "longLeg") {
legB = val;
legA = val / Math.sqrt(3);
hypotenuse = legA * 2;
} else {
hypotenuse = val;
legA = val / 2;
legB = legA * Math.sqrt(3);
}
resHTML = "Short Leg (a): " + legA.toFixed(4) + "" +
"Long Leg (b): " + legB.toFixed(4) + "" +
"Hypotenuse (c): " + hypotenuse.toFixed(4) + "" +
"Ratio used: 1 : √3 : 2";
}
resultContent.innerHTML = resHTML;
resultDiv.style.display = "block";
}
Understanding Special Right Triangles
In geometry, "special" right triangles are specific types of right triangles that have unique properties, making their side lengths predictable through established ratios. This allows you to solve for missing side lengths without needing the full Pythagorean theorem (a² + b² = c²) if you know at least one side length and the triangle type.
The 45°-45°-90° Triangle
Often called the isosceles right triangle, this triangle is formed by cutting a square in half diagonally. Because two of the angles are equal, the two legs (the sides adjacent to the 90° angle) are also equal in length.
Side Ratios: 1 : 1 : √2
Formula: If the legs are x, the hypotenuse is x√2.
Key Rule: To find the hypotenuse, multiply the leg by √2. To find a leg from the hypotenuse, divide the hypotenuse by √2.
The 30°-60°-90° Triangle
This triangle is formed by cutting an equilateral triangle in half. It has three distinct side lengths based on the angles opposite them.
Side Ratios: 1 : √3 : 2
Short Leg (opposite 30°): If this is x…
Long Leg (opposite 60°): This is x√3.
Hypotenuse (opposite 90°): This is 2x.
Real-World Example
Example 1: You have a 45-45-90 triangle and you know one leg is 10 units long. What is the hypotenuse?
Using the ratio (1 : 1 : √2), the hypotenuse is simply 10 * √2 ≈ 14.1421 units.
Example 2: You have a 30-60-90 triangle and the hypotenuse is 12 units long. What is the short leg?
Using the ratio (1 : √3 : 2), the short leg is half of the hypotenuse. 12 / 2 = 6 units. The long leg would then be 6 * √3 ≈ 10.3923 units.