Skip to content

Commit d24a2d1

Browse files
authored
Update Logic.html
1 parent 901800e commit d24a2d1

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Logic.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
}
2424

2525
static fromInput(inputId, outputId) {
26-
document.getElementById(inputId).addEventListener('keydown', function (e) {
27-
if (e.key === 'Enter') {
26+
document.getElementById('circle-radius').addEventListener('keydown', function (cr) {
27+
if (cr.key === 'Enter') {
2828
const radius = parseFloat(this.value);
2929
const circle = new Circle(radius);
3030
const calculatedArea = document.getElementById(outputId);
@@ -36,23 +36,21 @@
3636
});
3737
}
3838

39-
segmentArea(length, height) {
39+
segment(length, height) {
4040

4141
document.getElementById('segment-length').addEventListener('keydown', function (l) {
42-
if (l.key === 'Enter') {
42+
if (sl.key === 'Enter') {
4343
const length = parseFloat(this.value);
4444

45-
document.getElementById('segment-height').addEventListener('keydown', function (h) {
46-
if (h.key === 'Enter') {
45+
document.getElementById('segment-height').addEventListener('keydown', function (h) {
46+
if (sh.key === 'Enter') {
4747
const height = parseFloat(this.value);
4848

49-
const angle = Trig.queryAtan(this.height / this.length);
50-
51-
return angle / 90 * 3.2 * ((this.height ** 2 + this.length ** 2) / this.height) ** 2 - ((this.height ** 2 + this.length ** 2) / this.height - this.height) * this.length;
49+
const angle = Trig.queryAtan(this.height / this.length);
5250

53-
const circle = new Circle(r);
54-
const calculatedArea = circle.segmentArea(h);
55-
document.getElementById('segment-calculatedArea').innerText = `Segment area: ${segmentArea.toFixed(5)} units²`;
51+
const circle = new Circle(((this.height ** 2 + this.length ** 2) / this.height));
52+
const area = circle.area(((this.height ** 2 + this.length ** 2) / this.height)) * angle / 90 - ((this.height ** 2 + this.length ** 2) / this.height - this.height) * this.length;
53+
document.getElementById('segment-area').innerText = `Segment area: ${area.toFixed(5)} units²`;
5654
}
5755
});
5856
}

0 commit comments

Comments
 (0)