.trig-header { text-align: center; margin-bottom: 30px; }
.trig-header h2 { color: #2c3e50; font-size: 28px; margin-bottom: 10px; }
.trig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.trig-input-group { display: flex; flex-direction: column; }
.trig-input-group label { font-weight: 600; margin-bottom: 8px; color: #444; }
.trig-input-group input { padding: 12px; border: 2px solid #e0e0e0; border-radius: 6px; font-size: 16px; transition: border-color 0.3s; }
.trig-input-group input:focus { border-color: #3498db; outline: none; }
.trig-calc-btn { background-color: #3498db; color: white; border: none; padding: 15px 30px; font-size: 18px; font-weight: bold; border-radius: 6px; cursor: pointer; width: 100%; transition: background-color 0.3s; }
.trig-calc-btn:hover { background-color: #2980b9; }
.trig-reset-btn { background-color: #95a5a6; color: white; border: none; padding: 10px; margin-top: 10px; border-radius: 6px; cursor: pointer; width: 100%; }
.trig-result-box { margin-top: 30px; padding: 20px; background-color: #f8f9fa; border-left: 5px solid #3498db; border-radius: 4px; display: none; }
.trig-result-box h3 { margin-top: 0; color: #2c3e50; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.trig-result-item { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 17px; }
.trig-result-val { font-weight: bold; color: #2980b9; }
.trig-error { color: #e74c3c; font-weight: bold; margin-bottom: 15px; display: none; text-align: center; }
.trig-diagram { text-align: center; margin: 20px 0; }
.trig-info-section { margin-top: 40px; border-top: 1px solid #eee; padding-top: 30px; }
.trig-info-section h3 { color: #2c3e50; font-size: 24px; }
.trig-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.trig-table th, .trig-table td { border: 1px solid #ddd; padding: 12px; text-align: left; }
.trig-table th { background-color: #f2f2f2; }
@media (max-width: 600px) { .trig-grid { grid-template-columns: 1fr; } }
function solveTriangle() {
var a = parseFloat(document.getElementById('sideA').value);
var b = parseFloat(document.getElementById('sideB').value);
var c = parseFloat(document.getElementById('sideC').value);
var angleA = parseFloat(document.getElementById('angleA').value);
var error = document.getElementById('errorMessage');
var results = document.getElementById('trigResults');
error.style.display = 'none';
results.style.display = 'none';
var count = 0;
if (!isNaN(a)) count++;
if (!isNaN(b)) count++;
if (!isNaN(c)) count++;
if (!isNaN(angleA)) count++;
if (count = c) { error.innerHTML = "Hypotenuse must be longer than Side A"; error.style.display = "block"; return; }
b = Math.sqrt(c * c – a * a);
radA = Math.asin(a / c);
angleA = radA * (180 / Math.PI);
} else if (!isNaN(b) && !isNaN(c)) {
if (b >= c) { error.innerHTML = "Hypotenuse must be longer than Side B"; error.style.display = "block"; return; }
a = Math.sqrt(c * c – b * b);
radA = Math.acos(b / c);
angleA = radA * (180 / Math.PI);
}
// Case 2: One side and Angle A known
else if (!isNaN(angleA)) {
if (angleA = 90) { error.innerHTML = "Angle must be between 0 and 90 degrees"; error.style.display = "block"; return; }
radA = angleA * (Math.PI / 180);
if (!isNaN(a)) {
c = a / Math.sin(radA);
b = a / Math.tan(radA);
} else if (!isNaN(b)) {
a = b * Math.tan(radA);
c = b / Math.cos(radA);
} else if (!isNaN(c)) {
a = c * Math.sin(radA);
b = c * Math.cos(radA);
}
}
var angleB = 90 – angleA;
var area = 0.5 * a * b;
var perimeter = a + b + c;
document.getElementById('resSideA').innerText = a.toFixed(4);
document.getElementById('resSideB').innerText = b.toFixed(4);
document.getElementById('resSideC').innerText = c.toFixed(4);
document.getElementById('resAngleA').innerText = angleA.toFixed(2) + "°";
document.getElementById('resAngleB').innerText = angleB.toFixed(2) + "°";
document.getElementById('resArea').innerText = area.toFixed(4);
document.getElementById('resPerimeter').innerText = perimeter.toFixed(4);
results.style.display = 'block';
}
function resetTrigCalc() {
document.getElementById('sideA').value = ";
document.getElementById('sideB').value = ";
document.getElementById('sideC').value = ";
document.getElementById('angleA').value = ";
document.getElementById('trigResults').style.display = 'none';
document.getElementById('errorMessage').style.display = 'none';
}
Right Triangle Trigonometry Solver
Enter any two values (at least one side) to calculate all missing sides and angles.
Please enter at least two values, including at least one side length.
Results
Side A: –
Side B: –
Side C (Hypotenuse): –
Angle A: –
Angle B: –
Area: –
Perimeter: –
Understanding Trigonometry Calculations
Trigonometry is the branch of mathematics dealing with the relationships between the sides and angles of triangles. For a right-angled triangle (where one angle is 90 degrees), we use specific ratios known as Sine, Cosine, and Tangent.
The Core Formulas (SOH CAH TOA)
Using Angle A as the reference point:
- Sine (sin): Opposite / Hypotenuse (a / c)
- Cosine (cos): Adjacent / Hypotenuse (b / c)
- Tangent (tan): Opposite / Adjacent (a / b)
- Pythagorean Theorem: a² + b² = c²
Common Trig Values
| Angle (°) | Sine (sin) | Cosine (cos) | Tangent (tan) |
|---|---|---|---|
| 0° | 0 | 1 | 0 |
| 30° | 0.5 | 0.866 | 0.577 |
| 45° | 0.707 | 0.707 | 1 |
| 60° | 0.866 | 0.5 | 1.732 |
| 90° | 1 | 0 | Undefined |
Real-World Example
Imagine you are leaning a 10-foot ladder against a wall. If the ladder makes a 60-degree angle with the ground, how high up the wall does it reach?
Given: Hypotenuse (c) = 10, Angle (A) = 60°.
Calculation: Side A = sin(60°) × 10 = 0.866 × 10 = 8.66 feet.