Parabola II: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
var f = board.create('glider', [1, 0, board.defaultAxes.x], {name:"f"}); | var f = board.create('glider', [1, 0, board.defaultAxes.x], {name:"f"}); | ||
var c = board.create('glider', [-1, 0, board.defaultAxes.x], {name:"c"}); | var c = board.create('glider', [-1, 0, board.defaultAxes.x], {name:"-c"}); | ||
var l = board.create('parallel', [board.defaultAxes.y, c], {name:"l", withLabel:true}); | var l = board.create('parallel', [board.defaultAxes.y, c], {name:"l", withLabel:true}); | ||
var par = board.create('parabola', [f, l]); | var par = board.create('parabola', [f, l]); | ||
var P = board.create('glider', [2, 2, par], {name: ' | var P = board.create('glider', [2, 2, par], {name: 'p'}); | ||
var s1 = board.create('segment', [f,P]); | var s1 = board.create('segment', [f,P]); | ||
Line 18: | Line 18: | ||
var s2 = board.create('segment', [q, P]); | var s2 = board.create('segment', [q, P]); | ||
var txt = board.create('text', [0.2, 4, () => "| | var txt = board.create('text', [0.2, 4, () => "|pf| - |pq| = " + P.Dist(f).toFixed(2) + ' - ' + P.Dist(q).toFixed(2) + ' = ' + (P.Dist(f) - P.Dist(q)).toFixed(2)]); | ||
</jsxgraph> | </jsxgraph> | ||
=== The underlying JavaScript code === | === The underlying JavaScript code === | ||
<source lang="javascript"> | <source lang="javascript"> | ||
JXG.Options.label.autoPosition = true; | |||
JXG.Options.text.fontSize = 16; | |||
JXG.Options.line.strokeWidth = 0.8; | |||
var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true, showClearTraces: true}); | |||
var f = board.create('glider', [1, 0, board.defaultAxes.x], {name:"f"}); | |||
var c = board.create('glider', [-1, 0, board.defaultAxes.x], {name:"-c"}); | |||
var l = board.create('parallel', [board.defaultAxes.y, c], {name:"l", withLabel:true}); | |||
var par = board.create('parabola', [f, l]); | |||
var P = board.create('glider', [2, 2, par], {name: 'p'}); | |||
var s1 = board.create('segment', [f,P]); | |||
var q = board.create('point', [()=>c.X(), ()=>P.Y()], {name:'q'}); | |||
var s2 = board.create('segment', [q, P]); | |||
var txt = board.create('text', [0.2, 4, () => "|pf| - |pq| = " + P.Dist(f).toFixed(2) + ' - ' + P.Dist(q).toFixed(2) + ' = ' + (P.Dist(f) - P.Dist(q)).toFixed(2)]); | |||
</source> | </source> | ||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Geometry]] | [[Category:Geometry]] |
Latest revision as of 09:26, 29 June 2021
The underlying JavaScript code
JXG.Options.label.autoPosition = true;
JXG.Options.text.fontSize = 16;
JXG.Options.line.strokeWidth = 0.8;
var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true, showClearTraces: true});
var f = board.create('glider', [1, 0, board.defaultAxes.x], {name:"f"});
var c = board.create('glider', [-1, 0, board.defaultAxes.x], {name:"-c"});
var l = board.create('parallel', [board.defaultAxes.y, c], {name:"l", withLabel:true});
var par = board.create('parabola', [f, l]);
var P = board.create('glider', [2, 2, par], {name: 'p'});
var s1 = board.create('segment', [f,P]);
var q = board.create('point', [()=>c.X(), ()=>P.Y()], {name:'q'});
var s2 = board.create('segment', [q, P]);
var txt = board.create('text', [0.2, 4, () => "|pf| - |pq| = " + P.Dist(f).toFixed(2) + ' - ' + P.Dist(q).toFixed(2) + ' = ' + (P.Dist(f) - P.Dist(q)).toFixed(2)]);