Continuous functions: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 8: Line 8:
  b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
  b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
  b1axisy = board.createElement('axis', [[0,0], [0,1]], {});
  b1axisy = board.createElement('axis', [[0,0], [0,1]], {});
  graph = board.createElement('curve', ['x',
 
    function(x) {
  var f = function(x) {
       if (x<1) {
       if (x<1) {
           return 0.5*x*x;
           return 0.5*x*x;
Line 15: Line 15:
         return x+1;
         return x+1;
       }
       }
       }, 'x'], {curveType:'graph',strokeColor:'#00ff00'});
       };
graph = board.createElement('curve', ['x',f, 'x'], {curveType:'graph',strokeColor:'#00ff00'});
 
s = board.createElement('slider', [0,-2,4,0,1,1],{name:' '});
 
x1 = board.createElement('glider', [-2,0,b1axisx],{name:' '});
x2 = board.createElement('point', [function(){return x1.X()-s.X();},0],{style:7,name:' '});
x3 = board.createElement('point', [function(){return x1.X()+s.X();},0],{style:7,name:' '});
y1 = board.createElement('point', [function(){return x1.X();},function(){return f(x1.X());}],{style:7,name:' '});
y2 = board.createElement('point', [function(){return x2.X();},function(){return f(x2.X());}],{style:7,name:' '});
y3 = board.createElement('point', [function(){return x3.X();},function(){return f(x3.X());}],{style:7,name:' '});


      s = board.createElement('slider', [0,-2,4,0,1,1],{name:' '});


      x1 = board.createElement('glider', [-2,0,b1axisx],{name:' '});
v2 = board.createElement('curve', [function(t){return x2.X();},function(t){return t}], {strokeColor:'red',dash:1});
      x2 = board.createElement('point', [function(){return x1.X()-s.X();},0],{style:7,name:' '});
v3 = board.createElement('curve', [function(t){return x3.X();},function(t){return t}], {strokeColor:'red',dash:1});
      x3 = board.createElement('point', [function(){return x1.X()+s.X();},0],{style:7,name:' '});
      v2 = board.createElement('curve', [function(t){return x2.X();},function(t){return t}], {strokeColor:'red',dash:1});
      v3 = board.createElement('curve', [function(t){return x3.X();},function(t){return t}], {strokeColor:'red',dash:1});


</script>
</script>

Revision as of 10:57, 17 December 2008

References

The underlying JavaScript source code