|
2 | 2 | <html class="no-js" lang="en"> |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8"> |
5 | | - <style> |
6 | | - body {font-family: Helvetica, sans-serif;} |
7 | | - table {background-color:#CCDDEE;text-align:left} |
8 | | - </style> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <link rel="stylesheet" href="https://interactivecomputergraphics.github.io/physics-simulation/examples/style.css"> |
9 | 7 | <script type="text/x-mathjax-config"> |
10 | 8 | MathJax.Hub.Config({ |
11 | 9 | extensions: ["tex2jax.js"], |
|
18 | 16 | "HTML-CSS": { fonts: ["TeX"] } |
19 | 17 | }); |
20 | 18 | </script> |
21 | | - <script type="text/javascript" aync src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js"></script> |
| 19 | + <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js"></script> |
22 | 20 | <script src="https://cdn.plot.ly/plotly-2.5.1.min.js"></script> |
23 | 21 | <title>Mass-Spring-Damper Model</title> |
24 | 22 | </head> |
25 | 23 | <body> |
| 24 | + |
| 25 | +<header class="page-header"> |
| 26 | + <h1>Mass-Spring-Damper Model</h1> |
| 27 | +</header> |
| 28 | + |
26 | 29 | <main> |
27 | | - <h1 style="text-align:center">Mass-Spring-Damper Model</h1> |
28 | | - <table style="align_center;border-radius: 20px;padding: 20px;margin:auto"> |
29 | | - <col width="700"> |
30 | | - <col width="400"> |
31 | | - <tr> |
32 | | - <td> |
33 | | - <canvas id="simCanvas" width="700" height="600" style="border:2px solid #000000;border-radius: 20px;background-color:#FFFFFF">Your browser does not support the HTML5 canvas tag.</canvas> |
34 | | - </td> |
35 | | - <td> |
36 | | - <div id="plotOutput" style="width: 600px; height: 600px;border:2px solid #000000;border-radius: 0px;background-color:#EEEEEE"></div> |
37 | | - </td> |
38 | | - </tr> |
39 | | - <tr> |
40 | | - <td> |
41 | | - <table> |
42 | | - <col width="200" style="padding-right:10px"> |
43 | | - <col width="100"> |
44 | | - <tr> |
45 | | - <td><label>Current time</label></td> |
46 | | - <td><span id="time">0.00</span> s</td> |
47 | | - </tr> |
48 | | - <tr> |
49 | | - <td><label>Time per sim. step</label></td> |
50 | | - <td><span id="timePerStep">0.00</span> ms</td> |
51 | | - </tr> |
52 | | - <tr> |
53 | | - <td><label for="timeStepSizeInput">Time step size</label></td> |
54 | | - <td><input onchange="gui.sim.timeStepSize=parseFloat(value)" id="timeStepSizeInput" type="number" value="0.01" step="0.001"></td> |
55 | | - </tr> |
56 | | - <tr> |
57 | | - <td><label for="restLengthInput">Rest length</label></td> |
58 | | - <td><input id="restLengthInput" type="number" value="4.0" step="0.1"></td> |
59 | | - </tr> |
60 | | - <tr> |
61 | | - <td><label for="stiffnessInput">Stiffness</label></td> |
62 | | - <td><input onchange="gui.sim.stiffness=parseFloat(value)" id="stiffnessInput" type="number" value="5.0" step="1.0"></td> |
63 | | - </tr> |
64 | | - <tr> |
65 | | - <td><label for="dampingInput">Damping</label></td> |
66 | | - <td><input onchange="gui.sim.damping=parseFloat(value)" id="dampingInput" type="number" value="0.0" step="0.01"></td> |
67 | | - </tr> |
68 | | - <tr> |
69 | | - <td><label for="massInput">Mass</label></td> |
70 | | - <td><input onchange="gui.sim.mass=parseFloat(value)" id="massInput" type="number" value="0.5" step="0.01"></td> |
71 | | - </tr> |
72 | | - <tr> |
73 | | - <td><label for="timeIntegrationInput">Time integration method</label></td> |
74 | | - <td><select onchange="gui.sim.timeIntegrationMethod=value" id="timeIntegrationInput"> |
75 | | - <option>Explicit Euler</option> |
76 | | - <option selected="selected">Symplectic Euler</option> |
77 | | - <option>Runge-Kutta 2</option> |
78 | | - <option>Implicit Euler</option> |
79 | | - </select> |
80 | | - </tr> |
81 | | - <tr> |
82 | | - <td></td> |
83 | | - <td><button onclick="gui.restart()" type="button" id="restart">Restart</button></td> |
84 | | - </tr> |
85 | | - <tr> |
86 | | - <td></td> |
87 | | - <td><button onclick="gui.doPause()" type="button" id="Pause">Pause</button></td> |
88 | | - </tr> |
89 | | - </table> |
90 | | - </td> |
91 | | - </tr> |
92 | | - <tr><td> |
| 30 | +<!-- Simulation panel: canvas + controls --> |
| 31 | + <div class="card sim-panel"> |
| 32 | + <div class="sim-canvas-wrap"> |
| 33 | + <div class="plots-grid" width="100%"> |
| 34 | + <canvas id="simCanvas" width="600" height="600" style="border:0px solid #000000;border-radius: 20px;background-color:#FFFFFF">Your browser does not support the HTML5 canvas tag.</canvas> |
| 35 | + <div id="plotOutput" style="width: 600px; height: 600px;border:0px solid #000000;border-radius: 0px;background-color:#EEEEEE"></div> |
| 36 | + </div> |
| 37 | + </div> |
| 38 | + </div> |
| 39 | + <div class="controls-panel" style="width: 100%;align:center;margin-left:auto;margin-right:auto"> |
| 40 | + <h3>Controls</h3> |
| 41 | + <div class="controls-grid" style="width: 400px;align:left"> |
| 42 | + <label>Current time</label> |
| 43 | + <span class="stat-value"><span id="time">0.00</span> s</span> |
| 44 | + |
| 45 | + <label>Time per sim. step</label></td> |
| 46 | + <span class="stat-value"><span id="timePerStep">0.00</span> ms</span> |
| 47 | + |
| 48 | + <label for="timeStepSizeInput">Time step size</label> |
| 49 | + <input onchange="gui.sim.timeStepSize=parseFloat(value)" id="timeStepSizeInput" type="number" value="0.01" step="0.001"> |
| 50 | + |
| 51 | + <label for="restLengthInput">Rest length</label> |
| 52 | + <input id="restLengthInput" type="number" value="4.0" step="0.1"> |
| 53 | + |
| 54 | + <label for="stiffnessInput">Stiffness</label> |
| 55 | + <input onchange="gui.sim.stiffness=parseFloat(value)" id="stiffnessInput" type="number" value="5.0" step="1.0"> |
| 56 | + |
| 57 | + <label for="dampingInput">Damping</label> |
| 58 | + <input onchange="gui.sim.damping=parseFloat(value)" id="dampingInput" type="number" value="0.0" step="0.01"> |
| 59 | + |
| 60 | + <label for="massInput">Mass</label> |
| 61 | + <input onchange="gui.sim.mass=parseFloat(value)" id="massInput" type="number" value="0.5" step="0.01"> |
| 62 | + |
| 63 | + <label for="timeIntegrationInput">Time integration method</label> |
| 64 | + <select onchange="gui.sim.timeIntegrationMethod=value" id="timeIntegrationInput"> |
| 65 | + <option>Explicit Euler</option> |
| 66 | + <option selected="selected">Symplectic Euler</option> |
| 67 | + <option>Runge-Kutta 2</option> |
| 68 | + <option>Implicit Euler</option> |
| 69 | + </select> |
| 70 | + |
| 71 | + <div class="full-width"> |
| 72 | + <button onclick="gui.restart()" id="restart">▶ Restart</button> |
| 73 | + </div> |
| 74 | + <div class="full-width"> |
| 75 | + <button onclick="gui.doPause()" id="Pause" class="btn-secondary">▮▮ Pause</button> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + |
| 80 | + <!-- Theory section --> |
| 81 | + <div class="card theory"> |
93 | 82 | <h2>Mass spring algorithm:</h2> |
94 | 83 | This example shows a mass spring system that consists of particles linked by damped springs: |
95 | 84 | <ol> |
@@ -149,8 +138,7 @@ <h3>2. Time integration</h3> |
149 | 138 | \end{align*}$$ |
150 | 139 | where $\mathbf f^{\text{ext}}$ are the external forces. |
151 | 140 |
|
152 | | - </td></tr> |
153 | | - </table> |
| 141 | + </div> |
154 | 142 |
|
155 | 143 | </main> |
156 | 144 |
|
|
0 commit comments