Parabola: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
(24 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
That means the numbers below ''a'', ''b'', and ''c'' are updated if the points ''A'', ''B'', and ''C'' are dragged. And other way round, | That means the numbers below ''a'', ''b'', and ''c'' are updated if the points ''A'', ''B'', and ''C'' are dragged. And other way round, | ||
these numbers are editable. | these numbers are editable. | ||
See [[Slider and function plot]] for an easier example howto plot a parabola. | |||
<jsxgraph box="box2" width="600" height="400"> | |||
hook = true; | |||
board2 = JXG.JSXGraph.loadBoardFromString('box2', 'eNrtmm1v2zYQgD/bv4JAPteS7DgvmCYgSZNh2NACbVe0eykgW7TNRRYNiUrsFP3vuzseJblTXtwZWT8oAVre8cijyOfupIDhT5evX11+eBf1w/eXb97+/PpVFAyOg9BzUj+c6DhPon4vzOKljH6XarqQ2Sz9s/R9eQhtcRh61AUmKpvpfBkbpbMo9JoSdMalWegc9NwA1VQvlzIzoHMtUM50Zgp1J6NgHHqVgLMnEfhStBjW9cJlvFZLEJJoFqeFDL1agd3ryB/4obcmYWOFDQm3KjGLaHQ8RpUVUL2Qar4w4JtMWQKHnvUoBLjUSVlEw8AfHoGJlehhdJ6oLDYSRNFjhVuWFUg/z1WlpjZpiyxeOS21cTU6V3OFu0ePMvTrh8GnYdk+j+dscbI7rZduVLA1JmiMsFZoX2bKOPvxtpNx04e1wxFG5pWHhnVlafvRMo0nMnWm64btpjJmE7RelqlR908M+7TQt+tqo0io9JumnufmCe2BZEZlpabzIgdsXnlhmYc27QW7aO7Uw6NraxwLVFZeTV42h1mRR1k7HLHWeuNGzD/8KpuHMv9IMo+xljjmRsnblc55hUavokM8PWyQJpUzE70gHTVJOdHGAAjBYHwUeixQR07wjwYQdTnHAXirfYgec11TH9ZAA6+0YmFZpdXSKeS6KKqwIIFPJ4WscHDh4+/VFU6NCupL4mLB+0RNUq60guTQCJtagQHrVhJO4un1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EZUd0ujj6DapdGWNHq0y9/f21C8/69G/r9Q9DsUOxT3guJFG4qnT0Zx2GXFDsXdUYRiXt+8wkt5dAeXroLBBsNC6Caf0TqdxHhFToRms5LRb28v38BhYhN1NpfKrDR3Mk/kTGVK5kaKX+w1rGu665VKVRhZUS7CRBbTXK3okkB8bUqZplJMnjhLc3DfXjKsVhkW8FBTI5OmFj9IWtT9fjgpQcro2i1e5GqI/RA2W8LYH/DWK7b64a12r0vY6tu7MXarPHfJ+R+tkHyx', 'Geonext'); | |||
</jsxgraph> | |||
<html> | <html> | ||
<table style="border: 0px solid black; text-align: center" width="500px"> | <table style="border: 0px solid black; text-align: center" width="500px"> | ||
<tr> | <tr> | ||
<tr><td><input type="text" id="print_a" size="2" maxlength="7" | <th style="border: 1px solid black" width="100px">a</th> | ||
<th style="border: 1px solid black" width="100px">b</th> | |||
<th style="border: 1px solid black" width="100px">c</th> | |||
</tr> | |||
<tr> | |||
<td><input type="text" id="print_a" size="2" maxlength="7" | |||
style="border:none; text-align:right; font-size:1.2em; " | style="border:none; text-align:right; font-size:1.2em; " | ||
onKeyUp="board2. | onKeyUp="board2.select('A').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true" | ||
></td><td><input type="text" id="print_b" size="2" maxlength="7" | ></td> | ||
<td><input type="text" id="print_b" size="2" maxlength="7" | |||
style="border:none; text-align:right; font-size:1.2em; " | style="border:none; text-align:right; font-size:1.2em; " | ||
onKeyUp="board2. | onKeyUp="board2.select('B').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true" | ||
></td><td><input type="text" id="print_c" size="2" maxlength="7" | ></td> | ||
<td><input type="text" id="print_c" size="2" maxlength="7" | |||
style="border:none; text-align:right; font-size:1.2em; " | style="border:none; text-align:right; font-size:1.2em; " | ||
onKeyUp="board2. | onKeyUp="board2.select('C').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true" | ||
></td></tr> | ></td> | ||
</table> | </tr> | ||
< | </table> | ||
</html> | |||
board = JXG.JSXGraph.initBoard('box', { | <jsxgraph box="box" width="600" height="400"> | ||
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 5, 7, -3], axis: true}); | |||
curve = board. | var curve = board.create('functiongraph', [function(t){ | ||
return board2.select('A').X() * t * t + board2.select('B').X() * t + board2.select('C').X(); | |||
}, -10, 10]); | |||
function print_table( | function print_table() { | ||
if (hook){ | if (hook){ | ||
document.getElementById('print_a').value = board2.select('A').X().toFixed(2); | |||
document.getElementById('print_b').value = board2.select('B').X().toFixed(2); | |||
document.getElementById('print_c').value = board2.select('C').X().toFixed(2); | |||
} | } | ||
}; | }; | ||
print_table_id = board2. | board2.addChild(board); | ||
</ | |||
print_table_id = board2.on('update', print_table); | |||
</jsxgraph> | |||
===The underlying JavaScript code=== | ===The underlying JavaScript code=== | ||
<source lang="html4strict"> | |||
<div id="box2" class='jxgbox' style="width:375px; height:150px;"></div> | |||
<table style="border: 0px solid black; text-align: center" width="500px"> | |||
<tr> | |||
<th style="border: 1px solid black" width="100px">a</th> | |||
<th style="border: 1px solid black" width="100px">b</th> | |||
<th style="border: 1px solid black" width="100px">c</th> | |||
</tr> | |||
<tr> | |||
<td><input type="text" id="print_a" size="2" maxlength="7" | |||
style="border:none; text-align:right; font-size:1.2em; " | |||
onKeyUp="board2.select('A').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true" | |||
></td> | |||
<td><input type="text" id="print_b" size="2" maxlength="7" | |||
style="border:none; text-align:right; font-size:1.2em; " | |||
onKeyUp="board2.select('B').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true" | |||
></td> | |||
<td><input type="text" id="print_c" size="2" maxlength="7" | |||
style="border:none; text-align:right; font-size:1.2em; " | |||
onKeyUp="board2.select('C').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true" | |||
></td> | |||
</tr> | |||
</table> | |||
<div id="box" class="jxgbox" style="width:600px; height:400px;"></div> | |||
</source> | |||
<source lang="javascript"> | <source lang="javascript"> | ||
hook = true; | hook = true; | ||
board2 = JXG.JSXGraph.loadBoardFromString('box2', 'eNrtmm1v2zYQgD/ | board2 = JXG.JSXGraph.loadBoardFromString('box2', 'eNrtmm1v2zYQgD/bv4JAPteS7D...Y6tu7MXarPHfJ+R+tkHyx', 'Geonext'); | ||
board = JXG.JSXGraph.initBoard('box', { | var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 5, 7, -3], axis: true}); | ||
curve = board. | var curve = board.create('functiongraph', [function(t){ | ||
return board2.select('A').X() * t * t + board2.select('B').X() * t + board2.select('C').X(); | |||
}, -10, 10]); | |||
function print_table( | function print_table() { | ||
if (hook){ | if (hook){ | ||
document.getElementById('print_a').value = board2.select('A').X().toFixed(2); | |||
document.getElementById('print_b').value = board2.select('B').X().toFixed(2); | |||
document.getElementById('print_c').value = board2.select('C').X().toFixed(2); | |||
} | } | ||
}; | }; | ||
print_table_id = board2. | board2.addChild(board); | ||
print_table_id = board2.on('update', print_table); | |||
</source> | </source> | ||
===GEONExT Construction used in this example=== | |||
[[Media:Sliders.gxt|Sliders.gxt]] | |||
[[Category:Old]] | |||
[[Category:Old]] |
Latest revision as of 20:39, 19 October 2024
This is an example for JSXGraph with two boards and so called hooks into HTML. That means the numbers below a, b, and c are updated if the points A, B, and C are dragged. And other way round, these numbers are editable.
See Slider and function plot for an easier example howto plot a parabola.
a | b | c |
---|---|---|
The underlying JavaScript code
<div id="box2" class='jxgbox' style="width:375px; height:150px;"></div>
<table style="border: 0px solid black; text-align: center" width="500px">
<tr>
<th style="border: 1px solid black" width="100px">a</th>
<th style="border: 1px solid black" width="100px">b</th>
<th style="border: 1px solid black" width="100px">c</th>
</tr>
<tr>
<td><input type="text" id="print_a" size="2" maxlength="7"
style="border:none; text-align:right; font-size:1.2em; "
onKeyUp="board2.select('A').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true"
></td>
<td><input type="text" id="print_b" size="2" maxlength="7"
style="border:none; text-align:right; font-size:1.2em; "
onKeyUp="board2.select('B').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true"
></td>
<td><input type="text" id="print_c" size="2" maxlength="7"
style="border:none; text-align:right; font-size:1.2em; "
onKeyUp="board2.select('C').moveTo([parseFloat(this.value),0]); board2.update(); board.update();" onfocus="hook=false;" onblur="hook=true"
></td>
</tr>
</table>
<div id="box" class="jxgbox" style="width:600px; height:400px;"></div>
hook = true;
board2 = JXG.JSXGraph.loadBoardFromString('box2', 'eNrtmm1v2zYQgD/bv4JAPteS7D...Y6tu7MXarPHfJ+R+tkHyx', 'Geonext');
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-5, 5, 7, -3], axis: true});
var curve = board.create('functiongraph', [function(t){
return board2.select('A').X() * t * t + board2.select('B').X() * t + board2.select('C').X();
}, -10, 10]);
function print_table() {
if (hook){
document.getElementById('print_a').value = board2.select('A').X().toFixed(2);
document.getElementById('print_b').value = board2.select('B').X().toFixed(2);
document.getElementById('print_c').value = board2.select('C').X().toFixed(2);
}
};
board2.addChild(board);
print_table_id = board2.on('update', print_table);