-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
86 lines (79 loc) · 2.95 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE HTML>
<html>
<head>
<title>Double Pendulum Simulation</title>
</head>
<body>
<h1> Welcome to the double pendulum simulation!
<script>
window.mass1="";
window.mass2="";
window.t1=0;
window.t2=0;
window.isSet=false;
//ADD CHECKS FOR THE SET BUTTON AS WELL AS CHANGE MESSAGE WHEN YOU INPUT ZERO FOR THE ANGLE
function m1() {
window.mass1=prompt("Please enter the first mass: ");
if (window.mass1!=null && window.mass1!="" && Number(window.mass1)>0)
document.getElementById("M1P").innerHTML="Mass 1 = "+window.mass1+" kg";
else
document.getElementById("M1P").innerHTML="Please enter a valid value.";
}
function m2() {
window.mass2=prompt("Please enter the second mass: ");
if (window.mass2!=null && window.mass2!="" && Number(window.mass2)>0) {
document.getElementById("M2P").innerHTML="Mass 2 = "+window.mass2+" kg";
}
else
document.getElementById("M2P").innerHTML="Please enter a valid value.";
}
function angle1() {
window.t1=prompt("Please enter the first angle (radians): ");
if (Number(window.t1)>=0)
document.getElementById("T1P").innerHTML="Angle 1 = "+window.t1+" radians";
else
document.getElementById("T1P").innerHTML="Please enter a valid value.";
}
function angle2() {
window.t2=prompt("Please enter the first angle (radians): ");
if (Number(window.t2)>=0)
document.getElementById("T2P").innerHTML="Angle 2 = "+window.t2+" radians";
else
document.getElementById("T2P").innerHTML="Please enter a valid value.";
}
function turnOffButtons() {
if (window.mass1<=0 || window.mass2<=0 || window.t1<0 || window.t2<0) {
document.getElementById("setP").innerHTML="Please set reasonable values for the pendula and the angles first.";
}
else {
document.getElementById("m1b").disabled=true;
document.getElementById("m2b").disabled=true;
document.getElementById("angle1b").disabled=true;
document.getElementById("angle2b").disabled=true;
document.getElementById("offButton").disabled=true;
setUp();
isSet=true;
}
}
</script>
<p><button id ="m1b" onclick="m1()">Mass 1</button></p>
<p><button id="m2b" onclick="m2()">Mass 2</button></p>
<p><button id="angle1b" onclick="angle1()">Angle 1</button></p>
<p><button id="angle2b" onclick="angle2()">Angle 2</button></p>
<p><button id="offButton" onclick="turnOffButtons()">Set</button></p>
<p id="M1P"></p>
<p id="M2P"></p>
<p id="T1P"></p>
<p id="T2P"></p>
<p id="setP"></p>
</h1>
<h2> To avoid unreasonably sized circles, please choose masses between 0-400 kg. <br> Scroll down to see the simulation.</h2>
<h3>
<div class="container">
<canvas id="layer1" style="position: absolute; left: 0; top: 620; z-index: 1;"> </canvas>
<canvas id="layer2" styel="position: absolute; left: 0; top: 620; z-index: 2;"> </canvas>
</div>
<script src="drawing.js"> </script>
</h3>
</body>
</html>