Law of Sines Calculator
Use this calculator to solve for missing sides or angles of a triangle using the Law of Sines. Enter any three known values (sides or angles) and the calculator will determine the remaining properties of the triangle.
Understanding the Law of Sines
The Law of Sines is a fundamental principle in trigonometry that relates the lengths of the sides of a triangle to the sines of its angles. It states that for any triangle with sides a, b, and c, and opposite angles A, B, and C respectively, the following relationship holds true:
a / sin(A) = b / sin(B) = c / sin(C)
This law is incredibly useful for solving triangles when you know certain combinations of sides and angles.
When to Use the Law of Sines
The Law of Sines is primarily used in the following scenarios to find missing sides or angles:
- Angle-Angle-Side (AAS): You know two angles and one non-included side. For example, if you know Angle A, Angle B, and Side a.
- Angle-Side-Angle (ASA): You know two angles and the included side. For example, if you know Angle A, Side c, and Angle B. (In this case, you can easily find the third angle C = 180° – A – B, converting it to an AAS case).
- Side-Side-Angle (SSA): You know two sides and a non-included angle. For example, if you know Side a, Side b, and Angle A. This is often referred to as the "ambiguous case" because sometimes two different triangles can be formed with the given information, or sometimes no triangle can be formed.
It's important to remember that the sum of the interior angles of any triangle is always 180 degrees.
How to Use the Calculator
To use the Law of Sines Calculator:
- Enter the values for any three known properties of your triangle (sides or angles).
- Ensure that angles are entered in degrees.
- Click the "Calculate" button.
- The calculator will display the values for the remaining sides and angles.
The Ambiguous Case (SSA)
When you are given two sides and a non-included angle (SSA), there might be more than one possible triangle that fits the description. This is known as the ambiguous case. Specifically:
- If the side opposite the given angle is too short, no triangle can be formed.
- If it's exactly the right length, a right-angled triangle is formed (one solution).
- If it's longer than the height but shorter than the adjacent side, two different triangles can be formed (two solutions).
- If it's longer than or equal to the adjacent side, only one triangle can be formed.
This calculator will typically provide the acute angle solution for the ambiguous case. If you suspect there might be a second solution, further manual calculation or a more advanced tool might be needed.
Examples
Example 1: Angle-Angle-Side (AAS)
Suppose you have a triangle where:
- Angle A = 30°
- Angle B = 70°
- Side a = 10 units
Using the calculator, input these three values. The calculator will determine:
- Angle C = 180° – 30° – 70° = 80°
- Side b = (a * sin(B)) / sin(A) = (10 * sin(70°)) / sin(30°) ≈ 18.794 units
- Side c = (a * sin(C)) / sin(A) = (10 * sin(80°)) / sin(30°) ≈ 19.696 units
Example 2: Side-Side-Angle (SSA – Ambiguous Case)
Consider a triangle with:
- Side a = 10 units
- Side b = 15 units
- Angle A = 30°
Input these values into the calculator. It will calculate:
- Angle B ≈ 48.590° (This is the acute angle solution)
- Angle C ≈ 101.410°
- Side c ≈ 19.606 units
Note: For this specific SSA case, there is also a second possible triangle where Angle B ≈ 131.410° (180° – 48.590°). If Angle B were 131.410°, then Angle C would be 18.590° and Side c would be approximately 6.376 units. This calculator provides the primary acute angle solution.
.law-of-sines-calculator {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 20px;
max-width: 700px;
margin: 20px auto;
box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}
.law-of-sines-calculator h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.law-of-sines-calculator .calculator-inputs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
.law-of-sines-calculator .input-group {
display: flex;
flex-direction: column;
}
.law-of-sines-calculator label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.law-of-sines-calculator input[type="number"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
width: 100%;
box-sizing: border-box;
}
.law-of-sines-calculator button {
grid-column: span 1;
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 10px;
}
.law-of-sines-calculator button:hover {
background-color: #0056b3;
}
.law-of-sines-calculator button:last-of-type {
background-color: #6c757d;
}
.law-of-sines-calculator button:last-of-type:hover {
background-color: #5a6268;
}
.law-of-sines-calculator .calculator-result {
margin-top: 20px;
padding: 15px;
border: 1px solid #e0e0e0;
border-radius: 4px;
background-color: #e9f7ef;
color: #28a745;
min-height: 50px;
}
.law-of-sines-calculator .calculator-result h3 {
color: #28a745;
margin-top: 0;
}
.law-of-sines-calculator .calculator-result p {
margin: 5px 0;
line-height: 1.5;
}
.law-of-sines-calculator .calculator-result p strong {
color: #333;
}
.law-of-sines-calculator .calculator-article {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #eee;
}
.law-of-sines-calculator .calculator-article h3 {
color: #333;
margin-bottom: 15px;
}
.law-of-sines-calculator .calculator-article p {
line-height: 1.6;
margin-bottom: 10px;
color: #444;
}
.law-of-sines-calculator .calculator-article .formula {
font-family: 'Courier New', Courier, monospace;
background-color: #eef;
padding: 10px;
border-radius: 4px;
text-align: center;
font-size: 1.1em;
margin: 15px 0;
}
.law-of-sines-calculator .calculator-article ol,
.law-of-sines-calculator .calculator-article ul {
margin-left: 20px;
margin-bottom: 10px;
color: #444;
}
.law-of-sines-calculator .calculator-article li {
margin-bottom: 5px;
}
.law-of-sines-calculator .calculator-article strong {
color: #333;
}
function calculateLawOfSines() {
var sideA = parseFloat(document.getElementById('sideA').value);
var angleA = parseFloat(document.getElementById('angleA').value);
var sideB = parseFloat(document.getElementById('sideB').value);
var angleB = parseFloat(document.getElementById('angleB').value);
var sideC = parseFloat(document.getElementById('sideC').value);
var angleC = parseFloat(document.getElementById('angleC').value);
var inputs = [
{ id: 'sideA', value: sideA, type: 'side', label: 'Side a' },
{ id: 'angleA', value: angleA, type: 'angle', label: 'Angle A' },
{ id: 'sideB', value: sideB, type: 'side', label: 'Side b' },
{ id: 'angleB', value: angleB, type: 'angle', label: 'Angle B' },
{ id: 'sideC', value: sideC, type: 'side', label: 'Side c' },
{ id: 'angleC', value: angleC, type: 'angle', label: 'Angle C' }
];
var knowns = inputs.filter(function(input) { return !isNaN(input.value); });
var unknowns = inputs.filter(function(input) { return isNaN(input.value); });
var resultDiv = document.getElementById('lawOfSinesResult');
resultDiv.innerHTML = "; // Clear previous results
if (knowns.length !== 3) {
resultDiv.innerHTML = 'Please enter exactly three values (sides or angles) to calculate the rest.';
return;
}
// Convert angles to radians for Math.sin/asin
var toRadians = function(deg) { return deg * (Math.PI / 180); };
var toDegrees = function(rad) { return rad * (180 / Math.PI); };
// Store current known values in a mutable object for calculations
var current = {
a: sideA, A: angleA,
b: sideB, B: angleB,
c: sideC, C: angleC
};
var solved = false;
var maxIterations = 10; // Prevent infinite loops in case of complex interdependencies
for (var i = 0; i 0.01) { // Allow for floating point inaccuracies
resultDiv.innerHTML = 'Error: The sum of the angles (' + angleSum.toFixed(2) + '°) does not equal 180°. Please check your angle inputs.';
return;
}
}
// Apply Law of Sines: a/sin(A) = b/sin(B) = c/sin(C)
// Find missing side
if (!isNaN(current.a) && !isNaN(current.A) && !isNaN(current.B) && isNaN(current.b)) {
if (current.A = 180) { resultDiv.innerHTML = 'Error: Angle A must be between 0 and 180 degrees.'; return; }
current.b = (current.a * Math.sin(toRadians(current.B))) / Math.sin(toRadians(current.A));
changedThisIteration = true;
}
if (!isNaN(current.a) && !isNaN(current.A) && !isNaN(current.C) && isNaN(current.c)) {
if (current.A = 180) { resultDiv.innerHTML = 'Error: Angle A must be between 0 and 180 degrees.'; return; }
current.c = (current.a * Math.sin(toRadians(current.C))) / Math.sin(toRadians(current.A));
changedThisIteration = true;
}
if (!isNaN(current.b) && !isNaN(current.B) && !isNaN(current.A) && isNaN(current.a)) {
if (current.B = 180) { resultDiv.innerHTML = 'Error: Angle B must be between 0 and 180 degrees.'; return; }
current.a = (current.b * Math.sin(toRadians(current.A))) / Math.sin(toRadians(current.B));
changedThisIteration = true;
}
if (!isNaN(current.b) && !isNaN(current.B) && !isNaN(current.C) && isNaN(current.c)) {
if (current.B = 180) { resultDiv.innerHTML = 'Error: Angle B must be between 0 and 180 degrees.'; return; }
current.c = (current.b * Math.sin(toRadians(current.C))) / Math.sin(toRadians(current.B));
changedThisIteration = true;
}
if (!isNaN(current.c) && !isNaN(current.C) && !isNaN(current.A) && isNaN(current.a)) {
if (current.C = 180) { resultDiv.innerHTML = 'Error: Angle C must be between 0 and 180 degrees.'; return; }
current.a = (current.c * Math.sin(toRadians(current.A))) / Math.sin(toRadians(current.C));
changedThisIteration = true;
}
if (!isNaN(current.c) && !isNaN(current.C) && !isNaN(current.B) && isNaN(current.b)) {
if (current.C = 180) { resultDiv.innerHTML = 'Error: Angle C must be between 0 and 180 degrees.'; return; }
current.b = (current.c * Math.sin(toRadians(current.B))) / Math.sin(toRadians(current.C));
changedThisIteration = true;
}
// Find missing angle (SSA case)
if (!isNaN(current.a) && !isNaN(current.b) && !isNaN(current.A) && isNaN(current.B)) {
if (current.A = 180) { resultDiv.innerHTML = 'Error: Angle A must be between 0 and 180 degrees.'; return; }
var sinB_val = (current.b * Math.sin(toRadians(current.A))) / current.a;
if (sinB_val > 1 || sinB_val 1 or < -1). This might indicate an impossible triangle.';
return;
}
current.B = toDegrees(Math.asin(sinB_val));
changedThisIteration = true;
}
if (!isNaN(current.a) && !isNaN(current.c) && !isNaN(current.A) && isNaN(current.C)) {
if (current.A = 180) { resultDiv.innerHTML = 'Error: Angle A must be between 0 and 180 degrees.'; return; }
var sinC_val = (current.c * Math.sin(toRadians(current.A))) / current.a;
if (sinC_val > 1 || sinC_val 1 or < -1). This might indicate an impossible triangle.';
return;
}
current.C = toDegrees(Math.asin(sinC_val));
changedThisIteration = true;
}
if (!isNaN(current.b) && !isNaN(current.a) && !isNaN(current.B) && isNaN(current.A)) {
if (current.B = 180) { resultDiv.innerHTML = 'Error: Angle B must be between 0 and 180 degrees.'; return; }
var sinA_val = (current.a * Math.sin(toRadians(current.B))) / current.b;
if (sinA_val > 1 || sinA_val 1 or < -1). This might indicate an impossible triangle.';
return;
}
current.A = toDegrees(Math.asin(sinA_val));
changedThisIteration = true;
}
if (!isNaN(current.b) && !isNaN(current.c) && !isNaN(current.B) && isNaN(current.C)) {
if (current.B = 180) { resultDiv.innerHTML = 'Error: Angle B must be between 0 and 180 degrees.'; return; }
var sinC_val = (current.c * Math.sin(toRadians(current.B))) / current.b;
if (sinC_val > 1 || sinC_val 1 or < -1). This might indicate an impossible triangle.';
return;
}
current.C = toDegrees(Math.asin(sinC_val));
changedThisIteration = true;
}
if (!isNaN(current.c) && !isNaN(current.a) && !isNaN(current.C) && isNaN(current.A)) {
if (current.C = 180) { resultDiv.innerHTML = 'Error: Angle C must be between 0 and 180 degrees.'; return; }
var sinA_val = (current.a * Math.sin(toRadians(current.C))) / current.c;
if (sinA_val > 1 || sinA_val 1 or < -1). This might indicate an impossible triangle.';
return;
}
current.A = toDegrees(Math.asin(sinA_val));
changedThisIteration = true;
}
if (!isNaN(current.c) && !isNaN(current.b) && !isNaN(current.C) && isNaN(current.B)) {
if (current.C = 180) { resultDiv.innerHTML = 'Error: Angle C must be between 0 and 180 degrees.'; return; }
var sinB_val = (current.b * Math.sin(toRadians(current.C))) / current.c;
if (sinB_val > 1 || sinB_val 1 or 0.01) {
resultDiv.innerHTML = 'Error: The calculated angles sum to ' + finalAngleSum.toFixed(4) + '°, which is not 180°. This might indicate an issue with the input or an ambiguous case not fully resolved.';
return;
}
}
// Display results
var output = '
Calculated Triangle Properties:
';
output += '
Side a: ' + current.a.toFixed(4) + ";
output += '
Angle A: ' + current.A.toFixed(4) + '°';
output += '
Side b: ' + current.b.toFixed(4) + ";
output += '
Angle B: ' + current.B.toFixed(4) + '°';
output += '
Side c: ' + current.c.toFixed(4) + ";
output += '
Angle C: ' + current.C.toFixed(4) + '°';
resultDiv.innerHTML = output;
}