Trigonometry is a branch of mathematics that studies relationships between side lengths and angles of triangles. In a right-angled triangle (a triangle where one angle is exactly 90 degrees), these relationships are governed by the Pythagorean Theorem and trigonometric ratios: Sine, Cosine, and Tangent.
The Core Formulas
Pythagorean Theorem: a² + b² = c² (where c is the hypotenuse).
Sine (sin α): Opposite / Hypotenuse (a / c)
Cosine (cos α): Adjacent / Hypotenuse (b / c)
Tangent (tan α): Opposite / Adjacent (a / b)
Example Calculation
Imagine you have a ladder leaning against a wall. The ladder (Hypotenuse) is 10 feet long, and the base of the ladder is 6 feet from the wall (Side b). To find how high the ladder reaches (Side a):
Use the Pythagorean Theorem: a² + 6² = 10²
a² + 36 = 100
a² = 64
a = 8 feet
To find the angle: cos(α) = 6/10 = 0.6. Using an inverse cosine, α ≈ 53.13°.
Common Trigonometry Table
Angle (°)
Sin
Cos
Tan
30°
0.500
0.866
0.577
45°
0.707
0.707
1.000
60°
0.866
0.500
1.732
function calculateTrig() {
var a = parseFloat(document.getElementById('sideA').value);
var b = parseFloat(document.getElementById('sideB').value);
var c = parseFloat(document.getElementById('sideC').value);
var angA = parseFloat(document.getElementById('angleA').value);
var errorDiv = document.getElementById('trig-error');
var resultsDiv = document.getElementById('trig-results');
errorDiv.style.display = 'none';
resultsDiv.style.display = 'none';
var inputs = 0;
if (!isNaN(a)) inputs++;
if (!isNaN(b)) inputs++;
if (!isNaN(c)) inputs++;
if (!isNaN(angA)) inputs++;
if (inputs = c) throw "Hypotenuse must be longer than Side a.";
b = Math.sqrt(c*c – a*a);
angA = Math.asin(a/c) * (180/Math.PI);
} else if (!isNaN(b) && !isNaN(c)) {
if (b >= c) throw "Hypotenuse must be longer than Side b.";
a = Math.sqrt(c*c – b*b);
angA = Math.acos(b/c) * (180/Math.PI);
} else if (!isNaN(angA) && !isNaN(c)) {
if (angA = 90) throw "Angle must be between 0 and 90 degrees.";
var rad = angA * (Math.PI/180);
a = c * Math.sin(rad);
b = c * Math.cos(rad);
} else if (!isNaN(angA) && !isNaN(a)) {
if (angA = 90) throw "Angle must be between 0 and 90 degrees.";
var rad = angA * (Math.PI/180);
c = a / Math.sin(rad);
b = a / Math.tan(rad);
} else if (!isNaN(angA) && !isNaN(b)) {
if (angA = 90) throw "Angle must be between 0 and 90 degrees.";
var rad = angA * (Math.PI/180);
c = b / Math.cos(rad);
a = b * Math.tan(rad);
} else {
throw "Invalid combination. Please provide at least one side length.";
}
var angB = 90 – angA;
var area = 0.5 * a * b;
document.getElementById('resA').innerText = a.toFixed(4);
document.getElementById('resB').innerText = b.toFixed(4);
document.getElementById('resC').innerText = c.toFixed(4);
document.getElementById('resAngleA').innerText = angA.toFixed(2);
document.getElementById('resAngleB').innerText = angB.toFixed(2);
document.getElementById('resArea').innerText = area.toFixed(4);
resultsDiv.style.display = 'block';
} catch (err) {
errorDiv.innerText = err;
errorDiv.style.display = 'block';
}
}
function resetTrig() {
document.getElementById('sideA').value = ";
document.getElementById('sideB').value = ";
document.getElementById('sideC').value = ";
document.getElementById('angleA').value = ";
document.getElementById('trig-results').style.display = 'none';
document.getElementById('trig-error').style.display = 'none';
}