Continuous functions: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<jsxgraph width="600" height="500" box="box"> | <jsxgraph width="600" height="500" box="box"> | ||
var board = JXG.JSXGraph.initBoard('box', { | var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 6, -4], axis: true}); | ||
board.suspendUpdate(); | board.suspendUpdate(); | ||
var f = function(x) { | var f = function(x) { | ||
Line 16: | Line 14: | ||
var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'}); | var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'}); | ||
var x1 = board.create('glider', [-2,0, | var x1 = board.create('glider', [-2,0,board.defaultAxes.x],{name:'a'}); | ||
board.suspendUpdate(); | board.suspendUpdate(); | ||
var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{ | var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{size:2,face:'[]',name:' '}); | ||
var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{ | var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{size:2,face:'[]',name:' '}); | ||
var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{ | var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'}); | ||
var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{ | var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{size:2,face:'[]',name:' '}); | ||
var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{ | var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{size:2,face:'[]',name:' '}); | ||
var v1 = board.create(' | var v1 = board.create('segment', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1}); | ||
var v2 = board.create('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1}); | 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 v3 = board.create('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1}); | ||
Line 30: | Line 28: | ||
var h2 = board.create('curve', [function(t){return t},function(t){return y2.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}); | var h3 = board.create('curve', [function(t){return t},function(t){return y3.Y();}], {strokeColor:'gray',dash:2,strokeWidth:1}); | ||
board.unsuspendUpdate(); | |||
</jsxgraph> | </jsxgraph> | ||
Line 40: | Line 38: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var board = JXG.JSXGraph.initBoard('box', { | var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 6, -4], axis: true}); | ||
board.suspendUpdate(); | board.suspendUpdate(); | ||
var f = function(x) { | var f = function(x) { | ||
Line 56: | Line 52: | ||
var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'}); | var s = board.create('slider', [[0,-1],[4,-1],[0,1,1]],{name:'ε'}); | ||
var x1 = board.create('glider', [-2,0, | var x1 = board.create('glider', [-2,0,board.defaultAxes.x],{name:'a'}); | ||
var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{ | board.suspendUpdate(); | ||
var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{ | var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{size:2,face:'[]',name:' '}); | ||
var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{ | var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{size:2,face:'[]',name:' '}); | ||
var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{ | var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'}); | ||
var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{ | var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{size:2,face:'[]',name:' '}); | ||
var v1 = board.create(' | var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{size:2,face:'[]',name:' '}); | ||
var v1 = board.create('segment', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1}); | |||
var v2 = board.create('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1}); | 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 v3 = board.create('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1}); |
Revision as of 13:06, 7 June 2011
References
The underlying JavaScript source code
var board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 6, -4], axis: true});
board.suspendUpdate();
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,board.defaultAxes.x],{name:'a'});
board.suspendUpdate();
var x2 = board.create('point', [function(){return x1.X()-s.Value();},0],{size:2,face:'[]',name:' '});
var x3 = board.create('point', [function(){return x1.X()+s.Value();},0],{size:2,face:'[]',name:' '});
var y1 = board.create('point', [function(){return x1.X();},function(){return f(x1.X());}],{size:2,face:'[]',name:'f(a)'});
var y2 = board.create('point', [function(){return x2.X();},function(){return f(x2.X());}],{size:2,face:'[]',name:' '});
var y3 = board.create('point', [function(){return x3.X();},function(){return f(x3.X());}],{size:2,face:'[]',name:' '});
var v1 = board.create('segment', [x1,y1],{strokeColor:'gray',dash:2,strokeWidth:1});
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();