Debian Codegraph @

examples/adg/watt.html

raw
1 <html>
2 <head>
3 <title>Lima&ccedil;on | JSXGraph Example</title>
4 <link rel="stylesheet" type="text/css" href="../../distrib/jsxgraph.css" />
5 <script type="text/javascript" src="../../distrib/jsxgraphcore.js"></script>
6 </head>
7 <body>
8 <div id="debug" style="display: none"></div>
9 <center>
10 <div style="width: 1000px;">
11 <div style="width:500px; height: 510px;">
12 <div id="jxgbox" class="jxgbox" style="width:500px; height:500px; text-align: left; float: left;"></div>
13 <div id="polynomials" style="display: none; width: 500px; height: 500px; margin-left: 10px; text-align: left; padding-left: -200px;"></div>
14 </div>
15
16 <div style="width: 800px; margin-top: 10px;">
17 <form>
18 <input type="button" onclick="chooseCoordinateSystem();" value="Choose coordinate system" />
19 <input type="button" onclick="generatePolynomials();" value="Generate system of polynomial equations" />
20 <br />
21 <input type="button" onclick="calculateLocus();" value="Calculate locus of T" />
22 <input type="button" onclick="showLocusEquation();" value="Show locus equation" />
23 <input type="button" onclick="showBoard();" value="Show board" />
24 <input type="button" onclick="showLocusTime(loc)" value="Show locus time" />
25 <br />
26 <input type="button" onclick="extend();" value="Extend the construction (with glider)" />
27 <input type="button" onclick="extendedLocus();" value="Calculate extended locus (based on glider C)" />
28 <input type="button" onclick="showLocusTime(loc2)" value="Show locus time" />
29 <br />
30 <input type="button" onclick="extend2();" value="Extend the construction" />
31 <input type="button" onclick="extendedLocus2();" value="Calculate extended locus" />
32 <input type="button" onclick="showLocusTime(loc3)" value="Show locus time" />
33 <input type="button" onclick="generatePolynomials2()" value="Equations 2" />
34 <br />
35 <input type="text" value="0.2" id="dim" size="3" />
36 <input type="button" onclick="dimConstruction();" value="Dim construction" />
37 <input type="button" onclick="dimLocus();" value="Dim locus" />
38 <input type="button" onclick="dimExtension();" value="Dim extension" />
39 <input type="button" onclick="dimExtension2();" value="Dim extension 2" />
40 <input type="button" onclick="dimLocus2();" value="Dim extended loci" />
41 <br />
42 <input type="button" onclick="runComparison();" value="Run comparison">
43 <input type="button" onclick="window.location.href=window.location.href.split('?')[0]" value="Reload" />
44 <input type="button" onclick="toggleOptimize();" id="opt" value="Optimization is off">
45 </form>
46 </div>
47 </div>
48 </center>
49 <script type="text/javascript">
50 /* <![CDATA[ */
51
52 board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-10, 10, 10, -10], axis: true, grid: false,
53 keepaspectratio: true, showcopyright: false});
54
55 A = board.createElement('point', [0, 0]);
56 B = board.createElement('point', [8, 0]);
57 c1 = board.createElement('circle', [A, 4]);//, {strokeOpacity: 0.3});
58
59 c2 = board.create('circle', [B, 3]);
60 G = board.create('glider', [c1], {name: 'G'});
61
62 c3 = board.create('circle', [G, 6]);
63 D = board.create('intersection', [c2, c3], {name: 'D'});
64
65 E = board.create('midpoint', [G, D], {name: 'E'});
66
67
68
69 loc = null;
70
71 tg=null;
72 tc=null;
73 ti=null;
74 tm=null;
75 loc2 = null;
76
77 tc2=null;
78 ti2=null;
79 tm2=null;
80 loc3 = null;
81
82 opt = false;
83
84 function chooseCoordinateSystem() {
85 var k, o;
86 document.getElementById('polynomials').style.display = 'none';
87 document.getElementById('jxgbox').style.display = 'block';
88 JXG.Math.Symbolic.generateSymbolicCoordinatesPartial(board, E, 'u', 'brace');
89
90 for(k in board.objects) {
91 o = board.objects[k];
92 if(o.elementClass == JXG.OBJECT_CLASS_POINT && o.label) {
93 o.label.setText(o.name + ' (' + o.symbolic.x + ', ' + o.symbolic.y + ')');
94 }
95 }
96
97 board.update();
98 JXG.Math.Symbolic.clearSymbolicCoordinates(board);
99 }
100
101 function generatePolynomials() {
102 var res = JXG.Math.Symbolic.generatePolynomials(board, E, true),
103 i, out = document.getElementById('polynomials');
104
105 out.innerHTML = '<ul>';
106 for(i=0; i<res.length; i++)
107 out.innerHTML += '<li>' + res[i] + ' = 0</li>';
108 out.innerHTML += '</ul>';
109 out.style.display = 'block';
110 document.getElementById('jxgbox').style.display = 'none';
111 }
112
113 function calculateLocus() {
114 loc = board.create('locus', [E], {strokeColor: 'black', strokeWidth: '2px'});
115 }
116
117 function showLocusEquation() {
118 var out = document.getElementById('polynomials');
119
120 out.innerHTML = '<ul>';
121 for(i=0; i<loc.eq.length; i++)
122 out.innerHTML += '<li>' + loc.eq[i] + ' = 0</li>';
123 out.innerHTML += '</ul>';
124 out.style.display = 'block';
125 document.getElementById('jxgbox').style.display = 'none';
126 }
127
128 function showBoard() {
129 document.getElementById('polynomials').style.display = 'none';
130 document.getElementById('jxgbox').style.display = 'block';
131 }
132
133 function dimConstruction() {
134 var c = [p3, p4, c1, g, p6, c2, p14_1], i, o = getDim();
135
136 if(p3.visProp['strokeOpacity'] == o)
137 o = 1.0;
138
139 for(i=0; i<c.length; i++) {
140 c[i].setProperty({strokeOpacity: o, fillOpacity: o});
141 }
142 }
143
144 function dimLocus() {
145 var o = getDim();
146
147 if(loc != null) {
148 if(loc.visProp['strokeOpacity'] == o)
149 o = 1.0;
150 loc.setProperty({strokeOpacity: o});
151 }
152 }
153
154 function dimLocus2() {
155 var o = getDim();
156
157 if(loc2 != null) {
158 if(loc2.visProp['strokeOpacity'] == o)
159 o = 1.0;
160 loc2.setProperty({strokeOpacity: o});
161 }
162 }
163
164 function extend() {
165 if(loc==null)
166 return;
167
168 board.suspendUpdate();
169 tg = board.create('glider', [loc]);
170
171 tc = board.create('circle', [tg, 3]);
172 ti = board.create('intersection', [tc, c1, 0], {color: 'blue'});
173 tm = board.create('midpoint', [tg, ti], {color: 'green'});
174 board.unsuspendUpdate();
175 }
176
177 function dimExtension() {
178 if(tg == null)
179 return;
180
181 var c = [tg, tc, ti, tm], i, o = getDim();
182
183 if(tg.visProp['strokeOpacity'] == o)
184 o = 1.0;
185
186 for(i=0; i<c.length; i++) {
187 c[i].setProperty({strokeOpacity: o, fillOpacity: o});
188 }
189 }
190
191 function getDim() {
192 return parseFloat(document.getElementById('dim').value);
193 }
194
195 function extendedLocus() {
196 loc2 = board.create('locus', [tm], {strokeColor: 'black', strokeWidth: '4px'});
197 }
198
199 function extend2() {
200 board.suspendUpdate();
201 tc2 = board.create('circle', [p14_1, 3]);
202 ti2 = board.create('intersection', [tc2, c1, 0], {color: 'blue'});
203 tm2 = board.create('midpoint', [p14_1, ti2], {color: 'green'});
204 board.unsuspendUpdate();
205 }
206
207 function dimExtension2() {
208 if(tg == null)
209 return;
210
211 var c = [tc2, ti2, tm2], i, o = getDim();
212
213 if(tc2.visProp['strokeOpacity'] == o)
214 o = 1.0;
215
216 for(i=0; i<c.length; i++) {
217 c[i].setProperty({strokeOpacity: o, fillOpacity: o});
218 }
219 }
220
221 function extendedLocus2() {
222 loc3 = board.create('locus', [tm2], {strokeColor: 'green', strokeWidth: '2px'});
223 }
224
225 function showLocusTime(l) {
226 document.getElementById('polynomials').style.display = 'block';
227 document.getElementById('jxgbox').style.display = 'none';
228
229 document.getElementById('polynomials').innerHTML = l.ctime;
230 }
231
232 function toggleOptimize() {
233 if(opt) {
234 board.options.locus.translateToOrigin = false;
235 board.options.locus.translateTo10 = false;
236 opt = false;
237 document.getElementById('opt').value = "Optimization is off";
238 } else {
239 board.options.locus.translateToOrigin = true;
240 board.options.locus.translateTo10 = true;
241 opt = true;
242 document.getElementById('opt').value = "Optimization is on";
243 }
244 }
245
246 function generatePolynomials2() {
247 var res = JXG.Math.Symbolic.generatePolynomials(board, tm2, true),
248 i, out = document.getElementById('polynomials');
249
250 out.innerHTML = '<ul>';
251 for(i=0; i<res.length; i++)
252 out.innerHTML += '<li>' + res[i] + ' = 0</li>';
253 out.innerHTML += '</ul>';
254 out.style.display = 'block';
255 document.getElementById('jxgbox').style.display = 'none';
256 }
257
258 function runComparison() {
259 calculateLocus();
260 extend();
261 extendedLocus();
262
263 window.location.href = window.location.href+'?time0='+loc.ctime+'&time1='+loc2.ctime;
264 }
265
266 function runComparison2() {
267 extend2();
268 extendedLocus2();
269
270 window.location.href = window.location.href+'&time2='+loc3.ctime;
271 }
272
273 (function(window, document, undefined) {
274 var r, time0, time1, time2, i;
275 if(window.location.href.indexOf('time1')>-1) {
276 r = window.location.href.split('?')[1].split('&');
277 for(i=0; i<r.length; i++) {
278 if(r[i].split('=')[0] == 'time0')
279 time0 = r[i].split('=')[1];
280
281 if(r[i].split('=')[0] == 'time1')
282 time1 = r[i].split('=')[1];
283
284 if(r[i].split('=')[0] == 'time2')
285 time2 = r[i].split('=')[1];
286 }
287
288 if(time1 === undefined)
289 return;
290
291 if(time2 === undefined) {
292 runComparison2();
293 return;
294 }
295
296 document.getElementById('polynomials').style.display = 'block';
297 document.getElementById('jxgbox').style.display = 'none';
298
299 document.getElementById('polynomials').innerHTML = 'chaining: ' + (parseFloat(time1)+parseFloat(time0)) + '<br />direct: ' + time2;
300 }
301 })(window, document);
302
303
304 /* ]]> */
305 </script>
306 <br/>
307 </body>
308 </html>