Skip to content

Commit ef2f1a9

Browse files
authored
Update index.html
1 parent 06ad908 commit ef2f1a9

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

index.html

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,22 +1421,26 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
14211421
return 5 * angle * radius ** 2 - (radius - height) * length / 2;
14221422
}
14231423

1424-
function updateSegmentArea() {
1425-
const length = parseFloat(document.getElementById('segment-length').value);
1426-
const height = parseFloat(document.getElementById('segment-height').value);
1427-
const thing = parseFloat(2 * height / length);
1428-
const angle = parseFloat(atan(this.thing).toFixed(5));
1429-
const cosine = parseFloat(cos(this.angle).toFixed(5));
1430-
const radius = length / 2 * cosine
1431-
if (isNaN(length) || isNaN(height)) {
1432-
document.getElementById('segment-area').innerText = '';
1433-
return;
1434-
}
1424+
function updateSegmentArea() {
1425+
const length = parseFloat(document.getElementById('segment-length').value);
1426+
const height = parseFloat(document.getElementById('segment-height').value);
14351427

1436-
document.getElementById('segment-area').innerText =
1437-
`Area: ${segmentArea(length, height).toFixed(5)} square units`;
1428+
if (isNaN(length) || isNaN(height)) {
1429+
document.getElementById('segment-area').innerText = '';
1430+
return;
14381431
}
14391432

1433+
const thing = 2 * height / length;
1434+
const angle = parseFloat(atan(thing).toFixed(5));
1435+
const cosine = parseFloat(cos(angle).toFixed(5));
1436+
const radius = length / (2 * cosine);
1437+
1438+
const area = segmentArea(length, height, angle, radius);
1439+
1440+
document.getElementById('segment-area').innerText =
1441+
`Area: ${area.toFixed(5)} square units`;
1442+
}
1443+
14401444
document.getElementById('segment-length').addEventListener('input', updateSegmentArea);
14411445
document.getElementById('segment-height').addEventListener('input', updateSegmentArea);
14421446
</script>

0 commit comments

Comments
 (0)