Continuous functions: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
< | <jsxgraph width="600" height="500" box="box"> | ||
var board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 50, unitY: 50}); | |||
board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 50, unitY: 50}); | |||
board.suspendUpdate(); | board.suspendUpdate(); | ||
b1axisx = board. | var b1axisx = board.create('axis', [[0,0], [1,0]], {}); | ||
b1axisy = board. | var b1axisy = board.create('axis', [[0,0], [0,1]], {}); | ||
var f = function(x) { | var f = function(x) { | ||
Line 16: | Line 12: | ||
} | } | ||
}; | }; | ||
graph = board. | var graph = board.create('functiongraph', [f], {strokeColor:'#00ff00'}); | ||
s = board. | var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'}); | ||
x1 = board. | var x1 = board.create('glider', [-2,0,b1axisx],{name:'a'}); | ||
x2 = board. | board.suspendUpdate(); | ||
x3 = board. | var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{style:7,name:' '}); | ||
y1 = board. | var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{style:7,name:' '}); | ||
y2 = board. | var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{style:7,name:'f(a)'}); | ||
y3 = board. | var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{style:7,name:' '}); | ||
v1 = board. | var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{style:7,name:' '}); | ||
v2 = board. | var v1 = board.create('line', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1,straightFirst:false,straightLast:false}); | ||
v3 = board. | var v2 = board.create('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1}); | ||
var v3 = board.create('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1}); | |||
h1 = board. | var h1 = board.create('curve', [function(t){return t},function(t){return y1.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
h2 = board. | var h2 = board.create('curve', [function(t){return t},function(t){return y2.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
h3 = board. | var h3 = board.create('curve', [function(t){return t},function(t){return y3.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
board.unsuspendUpdate(); | board.unsuspendUpdate(); | ||
</jsxgraph> | |||
</ | |||
=== References === | === References === | ||
Line 45: | Line 40: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 50, unitY: 50}); | var board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 50, unitY: 50}); | ||
board.suspendUpdate(); | board.suspendUpdate(); | ||
b1axisx = board. | var b1axisx = board.create('axis', [[0,0], [1,0]], {}); | ||
b1axisy = board. | var b1axisy = board.create('axis', [[0,0], [0,1]], {}); | ||
var f = function(x) { | var f = function(x) { | ||
Line 57: | Line 52: | ||
} | } | ||
}; | }; | ||
graph = board. | var graph = board.create('functiongraph', [f], {strokeColor:'#00ff00'}); | ||
s = board. | var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'}); | ||
x1 = board. | var x1 = board.create('glider', [-2,0,b1axisx],{name:'a'}); | ||
x2 = board. | var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{style:7,name:' '}); | ||
x3 = board. | var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{style:7,name:' '}); | ||
y1 = board. | var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{style:7,name:'f(a)'}); | ||
y2 = board. | var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{style:7,name:' '}); | ||
y3 = board. | var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{style:7,name:' '}); | ||
v1 = board. | var v1 = board.create('line', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1,straightFirst:false,straightLast:false}); | ||
v2 = board. | var v2 = board.create('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1}); | ||
v3 = board. | var v3 = board.create('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1}); | ||
h1 = board. | var h1 = board.create('curve', [function(t){return t},function(t){return y1.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
h2 = board. | var h2 = board.create('curve', [function(t){return t},function(t){return y2.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
h3 = board. | var h3 = board.create('curve', [function(t){return t},function(t){return y3.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
board.unsuspendUpdate(); | board.unsuspendUpdate(); | ||
</source> | </source> |
Revision as of 10:40, 25 March 2011
References
The underlying JavaScript source code
var board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 50, unitY: 50});
board.suspendUpdate();
var b1axisx = board.create('axis', [[0,0], [1,0]], {});
var b1axisy = board.create('axis', [[0,0], [0,1]], {});
var f = function(x) {
if (x<1) {
return 0.5*x*x;
} else {
return x+1;
}
};
var graph = board.create('functiongraph', [f], {strokeColor:'#00ff00'});
var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'});
var x1 = board.create('glider', [-2,0,b1axisx],{name:'a'});
var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{style:7,name:' '});
var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{style:7,name:' '});
var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{style:7,name:'f(a)'});
var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{style:7,name:' '});
var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{style:7,name:' '});
var v1 = board.create('line', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1,straightFirst:false,straightLast:false});
var v2 = board.create('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
var v3 = board.create('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});
var h1 = board.create('curve', [function(t){return t},function(t){return y1.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1});
var h2 = board.create('curve', [function(t){return t},function(t){return y2.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1});
var h3 = board.create('curve', [function(t){return t},function(t){return y3.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1});
board.unsuspendUpdate();