|
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 | <title>Region-Based Shape Matching</title> |
23 | 21 | </head> |
24 | 22 | <body> |
| 23 | + |
| 24 | +<header class="page-header"> |
| 25 | + <h1>Region-Based Shape Matching</h1> |
| 26 | +</header> |
| 27 | + |
25 | 28 | <main> |
26 | | - <h1 style="text-align:center">Region-Based Shape Matching</h1> |
| 29 | + <!-- Simulation panel: canvas + controls --> |
27 | 30 | <table style="align_center;border-radius: 20px;padding: 20px;margin:auto"> |
28 | | - <col width="1100"> |
29 | | - <col width="400"> |
| 31 | + <col width="75%"> |
| 32 | + <col width="25%"> |
30 | 33 | <tr> |
31 | 34 | <td> |
32 | | - <canvas id="simCanvas" width="1024" height="768" style="border:2px solid #000000;border-radius: 20px;background-color:#EEEEEE">Your browser does not support the HTML5 canvas tag.</canvas> |
| 35 | + <div class="card sim-panel"> |
| 36 | + <div class="sim-canvas-wrap"> |
| 37 | + <canvas id="simCanvas" width="1024" height="960" style="border:2px solid #000000;border-radius: 20px;background-color:#EEEEEE">Your browser does not support the HTML5 canvas tag.</canvas> |
| 38 | + </div> |
| 39 | + </div> |
33 | 40 | </td> |
34 | 41 | <td> |
35 | | - <table> |
36 | | - <col width="180" style="padding-right:10px"> |
37 | | - <col width="100"> |
38 | | - <tr> |
39 | | - <td><label>Current time</label></td> |
40 | | - <td><span id="time">0.00</span> s</td> |
41 | | - </tr> |
42 | | - <tr> |
43 | | - <td><label>Time per sim. step</label></td> |
44 | | - <td><span id="timePerStep">0.00</span> ms</td> |
45 | | - </tr> |
46 | | - <tr> |
47 | | - <td><label># particles</label></td> |
48 | | - <td><span id="numParticles">0</span></td> |
49 | | - </tr> |
50 | | - <tr> |
51 | | - <td><label for="widthInput">Width</label></td> |
52 | | - <td><input onchange="gui.restart()" id="widthInput" type="number" value="40" step="1"></td> |
53 | | - </tr> |
54 | | - <tr> |
55 | | - <td><label for="heightInput">Height</label></td> |
56 | | - <td><input onchange="gui.restart()" id="heightInput" type="number" value="30" step="1"></td> |
57 | | - </tr> |
58 | | - <tr> |
59 | | - <td><label for="fixedParticlesInput"># fixed particles</label></td> |
60 | | - <td><select onchange="gui.restart()" id="fixedParticlesInput"> |
61 | | - <option value="1">1</option> |
62 | | - <option value="2" selected="selected">2</option> |
63 | | - <option value="4">4</option> |
64 | | - </select></td> |
65 | | - </tr> |
66 | | - <tr> |
67 | | - <td><label for="regionHalfWidthInput">Region halfwidth</label></td> |
68 | | - <td><input onchange="gui.restart()" id="regionHalfWidthInput" type="number" step="1" min="1" value="1"></td> |
69 | | - </tr> |
70 | | - <tr> |
71 | | - <td><label for="timeStepSizeInput">Time step size</label></td> |
72 | | - <td><input onchange="gui.sim.timeStepSize=parseFloat(value)" id="timeStepSizeInput" type="number" value="0.01" step="0.001"></td> |
73 | | - </tr> |
74 | | - <tr> |
75 | | - <td><label for="stiffnessInput">Stiffness</label></td> |
76 | | - <td><input onchange="gui.sim.stiffness=parseFloat(value)" id="stiffnessInput" type="number" value="1.0" step="0.1"></td> |
77 | | - </tr> |
78 | | - <tr> |
79 | | - <td><label for="gravityInput">Gravity</label></td> |
80 | | - <td><input onchange="gui.sim.gravity=parseFloat(value)" id="gravityInput" type="number" value="-9.81" step="0.01"></td> |
81 | | - </tr> |
82 | | - <tr> |
83 | | - <td></td> |
84 | | - <td><button onclick="gui.restart()" type="button" id="restart">Restart</button></td> |
85 | | - </tr> |
86 | | - <tr> |
87 | | - <td></td> |
88 | | - <td><button onclick="gui.doPause()" type="button" id="Pause">Pause</button></td> |
89 | | - </tr> |
90 | | - </table> |
| 42 | + <div class="controls-panel"> |
| 43 | + <h3>Controls</h3> |
| 44 | + <div class="controls-grid"> |
| 45 | + <label>Current time</label> |
| 46 | + <span class="stat-value"><span id="time">0.00</span> s</span> |
| 47 | + |
| 48 | + <label>Time per sim. step</label> |
| 49 | + <span class="stat-value"><span id="timePerStep">0.00</span> ms</span> |
| 50 | + |
| 51 | + <label># particles</label> |
| 52 | + <span class="stat-value"><span id="numParticles">0</span></span> |
| 53 | + |
| 54 | + <label for="widthInput">Width</label> |
| 55 | + <input onchange="gui.restart()" id="widthInput" type="number" value="40" step="1"> |
| 56 | + |
| 57 | + <label for="heightInput">Height</label> |
| 58 | + <input onchange="gui.restart()" id="heightInput" type="number" value="30" step="1"> |
| 59 | + |
| 60 | + <label for="fixedParticlesInput"># fixed particles</label> |
| 61 | + <select onchange="gui.restart()" id="fixedParticlesInput"> |
| 62 | + <option value="1">1</option> |
| 63 | + <option value="2" selected="selected">2</option> |
| 64 | + <option value="4">4</option> |
| 65 | + </select> |
| 66 | + |
| 67 | + <label for="regionHalfWidthInput">Region halfwidth</label> |
| 68 | + <input onchange="gui.restart()" id="regionHalfWidthInput" type="number" step="1" min="1" value="1"> |
| 69 | + |
| 70 | + <label for="timeStepSizeInput">Time step size</label> |
| 71 | + <input onchange="gui.sim.timeStepSize=parseFloat(value)" id="timeStepSizeInput" type="number" value="0.01" step="0.001"> |
| 72 | + |
| 73 | + <label for="stiffnessInput">Stiffness</label> |
| 74 | + <input onchange="gui.sim.stiffness=parseFloat(value)" id="stiffnessInput" type="number" value="1.0" step="0.1"> |
| 75 | + |
| 76 | + <label for="gravityInput">Gravity</label> |
| 77 | + <input onchange="gui.sim.gravity=parseFloat(value)" id="gravityInput" type="number" value="-9.81" step="0.01"> |
| 78 | + |
| 79 | + <div class="full-width"> |
| 80 | + <button onclick="gui.restart()" id="restart">▶ Restart</button> |
| 81 | + </div> |
| 82 | + <div class="full-width"> |
| 83 | + <button onclick="gui.doPause()" id="Pause" class="btn-secondary">▮▮ Pause</button> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + </div> |
91 | 87 | </td> |
92 | 88 | </tr> |
93 | | - <tr><td> |
| 89 | + </table> |
| 90 | + <!-- Theory section --> |
| 91 | + <div class="card theory"> |
94 | 92 | <h2>Region-Based Shape Matching algorithm:</h2> |
95 | 93 | This example shows the region-based shape matching simulation method for deformable solids [BMM17]. |
96 | 94 | <ol> |
@@ -198,8 +196,7 @@ <h3>References</h3> |
198 | 196 | <li>[BMM17] Jan Bender, Matthias Müller, Miles Macklin. A Survey on Position Based Dynamics, 2017. Eurographics Tutorials, 2017</li> |
199 | 197 | </ul> |
200 | 198 |
|
201 | | - </td></tr> |
202 | | - </table> |
| 199 | + </div> |
203 | 200 |
|
204 | 201 | </main> |
205 | 202 |
|
@@ -763,10 +760,12 @@ <h3>References</h3> |
763 | 760 |
|
764 | 761 | getMousePos(canvas, event) |
765 | 762 | { |
766 | | - let rect = canvas.getBoundingClientRect(); |
| 763 | + const rect = canvas.getBoundingClientRect(); |
| 764 | + const scaleX = canvas.width / rect.width; // buffer / displayed size |
| 765 | + const scaleY = canvas.height / rect.height; |
767 | 766 | return { |
768 | | - x: event.clientX - rect.left, |
769 | | - y: event.clientY - rect.top |
| 767 | + x: (event.clientX - rect.left) * scaleX, |
| 768 | + y: (event.clientY - rect.top) * scaleY |
770 | 769 | }; |
771 | 770 | } |
772 | 771 |
|
|
0 commit comments