Ellipsis: 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 6: | Line 6: | ||
var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true, showClearTraces: true}); | var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true, showClearTraces: true}); | ||
var f1 = board.create('glider', [-2, 0, board.defaultAxes.x], {name:"f"}); | var f1 = board.create('glider', [-2, 0, board.defaultAxes.x], {name:"f'"}); | ||
var f2 = board.create('glider', [2, 0, board.defaultAxes.x], {name:"f | var f2 = board.create('glider', [2, 0, board.defaultAxes.x], {name:"f"}); | ||
var ell = board.create('ellipse', [f1, f2, [0,3]]); | var ell = board.create('ellipse', [f1, f2, [0,3]]); | ||
var P = board.create('glider', [-1, 2, ell], {name: ' | var P = board.create('glider', [-1, 2, ell], {name: 'p'}); | ||
var s1 = board.create('segment', [f1,P]); | var s1 = board.create('segment', [f1,P]); | ||
var s2 = board.create('segment', [f2,P]); | var s2 = board.create('segment', [f2,P]); | ||
var txt = board.create('text', [ | var txt = board.create('text', [0.2, 4, () => "|pf| + |pf'| = " + P.Dist(f1).toFixed(2) + ' + ' + P.Dist(f2).toFixed(2) + ' = ' + (P.Dist(f1) + P.Dist(f2)).toFixed(2)]); | ||
</jsxgraph> | </jsxgraph> | ||
Line 20: | Line 20: | ||
=== 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 f1 = board.create('glider', [-2, 0, board.defaultAxes.x], {name:"f'"}); | |||
var f2 = board.create('glider', [2, 0, board.defaultAxes.x], {name:"f"}); | |||
var ell = board.create('ellipse', [f1, f2, [0,3]]); | |||
var P = board.create('glider', [-1, 2, ell], {name: 'p'}); | |||
var s1 = board.create('segment', [f1,P]); | |||
var s2 = board.create('segment', [f2,P]); | |||
var txt = board.create('text', [0.2, 4, () => "|pf| + |pf'| = " + P.Dist(f1).toFixed(2) + ' + ' + P.Dist(f2).toFixed(2) + ' = ' + (P.Dist(f1) + P.Dist(f2)).toFixed(2)]); | |||
</source> | </source> | ||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Geometry]] | [[Category:Geometry]] |
Latest revision as of 09:23, 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 f1 = board.create('glider', [-2, 0, board.defaultAxes.x], {name:"f'"});
var f2 = board.create('glider', [2, 0, board.defaultAxes.x], {name:"f"});
var ell = board.create('ellipse', [f1, f2, [0,3]]);
var P = board.create('glider', [-1, 2, ell], {name: 'p'});
var s1 = board.create('segment', [f1,P]);
var s2 = board.create('segment', [f2,P]);
var txt = board.create('text', [0.2, 4, () => "|pf| + |pf'| = " + P.Dist(f1).toFixed(2) + ' + ' + P.Dist(f2).toFixed(2) + ' = ' + (P.Dist(f1) + P.Dist(f2)).toFixed(2)]);