chiark / gitweb /
dep-ui.js: Add the CAPTUREP argument to `addEventListener' calls.
[dep-ui] / rolling.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2           "http://www.w3c.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5   <title>Rolling wire-strip calculator</title>
6   <script type="text/javascript" src="dep.js"></script>
7   <script type="text/javascript" src="dep-ui.js"></script>
8   <link rel=stylesheet type="text/css" href="dep-ui.css">
9   <link rel=stylesheet type="text/css" href="rolling.css">
10 <head>
11 <body>
12
13 <h1>Rolling wire-strip calculator</h1>
14
15 <div id=trace style="white-space: pre"></div>
16 <script type="text/javascript"><!--
17 --></script>
18
19 <table class=widgets>
20   <tr><td colspan=2><h3>Required size</h3>
21   <tr>
22     <td class=label><label for=width>Width: </label>
23     <td><input id=width>
24     <script type="text/javascript"><!--
25         var width = new DEP.Dep();
26         DEP_UI.input_field('width', width, DEP_UI.convert_to_numeric);
27     --></script>
28   <tr>
29     <td class=label><label for=thick>Thickness: </label>
30     <td><input id=thick>
31     <script type="text/javascript"><!--
32         var thick = new DEP.Dep();
33         DEP_UI.input_field('thick', thick, DEP_UI.convert_to_numeric);
34     --></script>
35   <tr>
36     <td class=label><label for=length>Length: </label>
37     <td><input id=length>
38     <script type="text/javascript"><!--
39         var length = new DEP.Dep();
40         DEP_UI.input_field('length', length, DEP_UI.convert_to_numeric);
41     --></script>
42
43   <tr><td colspan=2><h3>You should start with</h3>
44   <tr>
45     <td class=label><label for=sq-size>Square side: </label>
46     <td><input id=sq-size readonly>
47     <script type="text/javascript"><!--
48         var sq_size = new DEP.Dep(function () {
49           return Math.pow(Math.pow(width.value(), 2) * thick.value(), 1/3);
50         });
51         DEP_UI.output_field('sq-size', sq_size, DEP_UI.convert_from_numeric);
52     --></script>
53   <tr>
54     <td class=label><label for=rnd-diam>Round diameter: </label>
55     <td><input id=rnd-diam readonly>
56     <script type="text/javascript"><!--
57         var rnd_diam = new DEP.Dep(function () {
58           return 2*sq_size.value()/Math.sqrt(Math.PI);
59         });
60         DEP_UI.output_field('rnd-diam', rnd_diam,
61                             DEP_UI.convert_from_numeric);
62     --></script>
63   <tr>
64     <td class=label><label for=start-length>Length: </label>
65     <td><input id=start-length readonly>
66     <script type="text/javascript"><!--
67         var volume = new DEP.Dep(function () {
68           return width.value() * thick.value() * length.value();
69         });
70         volume.name = 'volume';
71         var start_length = new DEP.Dep(function () {
72           return volume.value()/(Math.pow(sq_size.value(), 2));
73         });
74         DEP_UI.output_field('start-length', start_length,
75                             DEP_UI.convert_from_numeric);
76     --></script>
77
78   <tr><td colspan=2><h3>Initial stock</h3>
79   <tr><td colspan=2>
80     <input type=radio name=stock-type value=round id=stock-round checked>
81     <label for=stock-round>Round section</label>
82     <script type="text/javascript"><!--
83         var stock_type = new DEP.Dep();
84         DEP_UI.input_radio('stock-round', stock_type);
85     --></script>
86   <tr><td colspan=2>
87     <input type=radio name=stock-type value=square id=stock-square>
88     <label for=stock-square>Square section</label>
89     <script type="text/javascript"><!--
90         DEP_UI.input_radio('stock-square', stock_type);
91     --></script>
92   <tr>
93     <td class=label><label for=stock-size>Stock size: </label>
94     <td><input id=stock-size>
95     <script type="text/javascript"><!--
96         var stock_size = new DEP.Dep();
97         DEP_UI.input_field('stock-size', stock_size,
98                            DEP_UI.convert_to_numeric);
99     --></script>
100   <tr>
101     <td class=label><label for=stock-length>Stock length: </label>
102     <td><input id=stock-length readonly>
103     <script type="text/javascript"><!--
104         var stock_length = new DEP.Dep(function () {
105           var cross;
106           switch (stock_type.value()) {
107             case 'round':
108               cross = 1/4 * Math.PI * Math.pow(stock_size.value(), 2);
109               break;
110             case 'square':
111               cross = Math.pow(stock_size.value(), 2);
112               break;
113             default:
114               dep_bad();
115           }
116           return volume.value()/cross;
117         });
118         DEP_UI.output_field('stock-length', stock_length,
119                             DEP_UI.convert_from_numeric);
120     --></script>
121 </table>
122
123 <script type="text/javascript"><!--
124         function toggle_help() {
125           var e = DEP_UI.elt('help');
126           var b = DEP_UI.elt('toggle-help');
127           if (e.className.match(/\bconceal\b/)) {
128             b.textContent = 'Hide help';
129             DEP_UI.rm_elt_class(e, 'conceal');
130           } else {
131             b.textContent = 'Show help';
132             DEP_UI.add_elt_class(e, 'conceal');
133           }
134         }
135         document.write(
136           '<button id=toggle-help onclick="toggle_help()">' + 
137           'Show help</button>');
138 --></script>
139 <div id=help>
140 <script type="text/javascript"><!--
141         DEP_UI.add_elt_class(DEP_UI.elt('help'), 'conceal');
142 --></script>
143 <h2>What this program does</h2>
144
145 <div id=js-note>
146 <script type="text/javascript"><!--
147         DEP_UI.add_elt_class(DEP_UI.elt('js-note'), 'conceal');
148 --></script>
149 <p>This page is only really interesting because it contains a Javascript
150 program.  You seem to have Javascript turned off, so it won't work very
151 well.
152 </div>
153
154 <h3>Background</h3>
155
156 <p>When you pass round or square wire through flat rolls it gets flatter
157 and longer, but it also gets wider.  You can exploit this to make thin
158 wire strip of almost any dimensions, but it&rsquo;s rather difficult to
159 predict the result.  That&rsquo;s what this calculator does.
160
161 <p>You specify the width and thickness of the strip you want, and the
162 program calculates what size round or square wire you should start with.
163 Additionally, if you specify the length of strip you need, it will
164 calculate the length of the input wire.
165
166 <p>The chances are that you don&rsquo;t actually have the required
167 thickness of round or square wire to start with, but you do have some
168 that&rsquo;s thicker.  Just enter the size of the round or square
169 initial stock that you do have and the program will calculate how much
170 of it you need to create the required starting size that you can then
171 roll down to the required thickness of strip.
172
173 <p>For best results, roll the strip in as few passes as you can handle.
174
175 <p>You can see the <a href="rolling-eqn.html">detailed equations</a>
176 used for this calculation if you're interested.
177
178 <h3>Use</h3>
179
180 <p>Boxes with light red or white backgrounds are entry boxes for you to
181 type in your requirements; boxes with dark red or grey backgrounds are
182 where the calculator puts its answers.  White and grey mean that the box
183 is showing useful information: an input box contains a valid number, for
184 example, and an output box has calculated a correct answer.  Red, on the
185 other hand, means that there&rsquo;s something wrong: either the
186 calculator can&rsquo;t understand what you&rsquo;ve typed in an input
187 box, or it&rsquo;s hit trouble &ndash; usually this means that some
188 necessary input is missing.
189
190 <p>You specify the width and thickness of the strip you want, and the
191 program calculates what size round or square wire you should start with.
192 Additionally, if you specify the length of strip you need, it will
193 calculate the length of the input wire.
194
195 <p>You can use whatever units you like, as long as they are consistent,
196 but you cannot use wire gauges.  If you use millimetres, the results
197 will be in millimetres; if you use inches, the results will be in
198 inches.  Whatever you use, the results are displayed to only 3 decimal
199 places.
200
201 <h3>Code and credits</h3>
202
203 <p>The code which makes this page work
204 is <a href="http://www.gnu.org/philosophy/free-sw.html">free
205 software</a>.  You
206 can <a href="http://git.distorted.org.uk/~mdw/dep-ui/">browse or download
207 it</a>, modify it, and/or redistribute it under the terms of the
208 <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU
209 General Public License, version 2</a> or, at your option, any later
210 version.
211
212 <p>If you make interesting changes, I&rsquo;d be very grateful to know
213 about them.  Please <a href="mailto:mdw@distorted.org.uk">mail me
214 patches</a>.
215
216 <p>The JavaScript machinery on this page was written by Mark Wooding;
217 the text was written by Mark Wooding and Gary Wooding.  The data used
218 to derive the computation was provided by Gary Wooding.
219
220 </div>
221 </body>
222 </html>