forked from beltoforion/Educational-Javascripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtides.html
190 lines (166 loc) · 8.99 KB
/
tides.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="javascript_samples/tides/tides.js"></script>
<script src="javascript_samples/shared/vector.js"></script>
<link rel="stylesheet" type="text/css" href="./styles/index.css"/>
<link rel="stylesheet" type="text/css" href="./styles/article.css"/>
</head>
<body class="article">
<div>
<h2 class="article_caption">Example 3: Illustration of Tidal Forces</h2>
<p>
This is the demonstration page of the tidal simulation javascript applet. For more details about
the please turn to the <a href="http://articles.beltoforion.de/article.php?a=tides_explained" target="_blank">original tidal simulation article.</a>
</p>
<table class="noborder">
<tr>
<td class="noborder">
<canvas id="cvTides2" width="800" height="800"></canvas>
</td>
<td class="noborder">
<form>
<h2>Animation Settings</h2>
<fieldset>
<b>Run / Stop</b><br/>
<button type="button" id="btnRun" onClick="onClickRunStop()" style="width:120px; height:50px;">Run</button>
<button type="button" id="btnNeapTide" onClick="onClickNeapTide()" style="width:120px; height:50px;">Neap Tide</button>
<button type="button" id="btnSpringTide" onClick="onClickSpringTide()" style="width:120px; height:50px;">Spring Tide</button>
</fieldset>
<fieldset>
<b>Look at</b>
<select id="cbViewPoint" name="viewpoint" onChange="onChangeViewPoint()">
<option value="Earth">Earth</option>
<option value="CenterOfMass">Center of Mass</option>
</select>
</fieldset>
<fieldset>
<b>Render Features</b><br/>
<input type="checkbox" name="show orbits" value="true" id="cbShowOrbits" onChange="onShowOrbits()"/>
Show Orbits<br/>
<input type="checkbox" name="show orbits" value="true" id="cbShowMoon" onChange="onShowMoon()"/>
Show Moon<br/>
<input type="checkbox" name="show orbits" value="true" id="cbShowSun" onChange="onShowSun()"/>
Show Sun<br/>
</fieldset>
<fieldset>
<b>Force display</b><br/>
<input type="checkbox" name="force" value="true" id="cbShowTidalAcc" onChange="onShowTidalAcc()"/>
Show Tidal Acceleration (Moon)<br/>
<input type="checkbox" name="force" value="true" id="cbShowTidalAccSun" onChange="onShowTidalAccSun()"/>
Show Tidal Acceleration (Sun)<br/>
<input type="checkbox" name="force" value="true" id="cbShowOcean" onChange="onShowOcean()"/>
Show Ocean<br/>
<input type="checkbox" name="force" value="true" id="cbShowGravAcc" onChange="onShowGravAcc()"/>
Show Gravitational Acceleration (Moon)<br/>
<input type="checkbox" name="force" value="true" id="cbShowCentAcc" onChange="onShowCentAcc()"/>
Show Centrifugal Acceleration<br/>
<input type="checkbox" name="show orbits" value="true" id="cbShowSurfacePoints" onChange="onShowSurfacePoints()"/>
Show Centrifugal Acceleration Sample Points<br/>
<input type="checkbox" name="force" value="true" id="cbScaleForceToModel" onChange="onScaleForceToModel()"/>
Match Vector Directions to Model Scale<br/>
</fieldset>
</form>
</td>
</tr>
</table>
</div>
<script>
var tidalModel = tidalSimulation({ cvid : 'cvTides2',
path : './javascript_samples/tides',
lookAtTarget : 'CenterOfMass',
autoMove : true,
setup : 1,
isRunning : true,
showSun : true,
scaleForceToModel : false,
showMoon : true,
showMoonOrbit : true,
showEarthOrbit : true,
showSurfacePoints : false,
showGravAcc : false,
showCentAcc : false,
showTidalAcc : true,
showTidalAccSun : true,
showAccSum : true });
updateControls()
function updateControls() {
// Set up formular controls
document.getElementById("cbViewPoint").value = tidalModel.config.lookAtTarget;
document.getElementById("cbShowOrbits").checked = tidalModel.config.showEarthOrbit || model2.config.showMoonOrbit;
document.getElementById("cbShowSurfacePoints").checked = tidalModel.config.showSurfacePoints;
document.getElementById("cbShowTidalAcc").checked = tidalModel.config.showTidalAcc;
document.getElementById("cbShowTidalAccSun").checked = tidalModel.config.showTidalAccSun;
document.getElementById("cbShowOcean").checked = tidalModel.config.showAccSum;
document.getElementById("cbShowGravAcc").checked = tidalModel.config.showGravAcc;
document.getElementById("cbShowCentAcc").checked = tidalModel.config.showCentAcc;
document.getElementById("cbShowMoon").checked = tidalModel.config.showMoon;
document.getElementById("cbShowSun").checked = tidalModel.config.showSun;
document.getElementById("cbScaleForceToModel").checked = tidalModel.config.scaleForceToModel;
if (tidalModel.config.autoMove) {
document.getElementById("btnRun").innerHTML = "Stop";
} else {
document.getElementById("btnRun").innerHTML = "Run";
}
}
function onChangeViewPoint() {
tidalModel.config.lookAtTarget = document.getElementById("cbViewPoint").value;
}
function onShowOrbits() {
var check = document.getElementById("cbShowOrbits").checked;
tidalModel.config.showEarthOrbit = check;
tidalModel.config.showMoonOrbit = check;
}
function onShowSurfacePoints() {
tidalModel.config.showSurfacePoints = document.getElementById("cbShowSurfacePoints").checked;
}
function onShowTidalAcc() {
tidalModel.config.showTidalAcc = document.getElementById("cbShowTidalAcc").checked;
}
function onShowTidalAccSun() {
tidalModel.config.showTidalAccSun = document.getElementById("cbShowTidalAccSun").checked;
}
function onShowOcean() {
tidalModel.config.showAccSum = document.getElementById("cbShowOcean").checked;
}
function onShowGravAcc() {
tidalModel.config.showGravAcc = document.getElementById("cbShowGravAcc").checked;
}
function onShowCentAcc() {
tidalModel.config.showCentAcc = document.getElementById("cbShowCentAcc").checked;
}
function onShowSun() {
tidalModel.config.showSun = document.getElementById("cbShowSun").checked;
}
function onShowMoon() {
tidalModel.config.showMoon = document.getElementById("cbShowMoon").checked;
}
function onScaleForceToModel() {
tidalModel.setScaleForceToModel(document.getElementById("cbScaleForceToModel").checked);
}
function onClickRunStop() {
if (tidalModel.config.autoMove == false) {
tidalModel.config.autoMove = true
} else {
tidalModel.config.autoMove = false
}
updateControls()
}
function onClickNeapTide() {
tidalModel.config.autoMove = false
tidalModel.setPositions(Math.PI, Math.PI*1.5)
tidalModel.update()
tidalModel.render()
updateControls()
}
function onClickSpringTide() {
tidalModel.config.autoMove = false
tidalModel.setPositions(Math.PI*.5, Math.PI*1.5)
tidalModel.update()
tidalModel.render()
updateControls()
}
</script>
</body>
</html>