Difference between revisions of "Continuous functions"

From JSXGraph Wiki
Jump to navigationJump to search
Line 61: Line 61:
 
  s = board.createElement('slider', [0,-2,4,0,1,1],{name:' '});
 
  s = board.createElement('slider', [0,-2,4,0,1,1],{name:' '});
  
  x1 = board.createElement('glider', [-2,0,b1axisx],{name:' '});
+
  y1 = board.createElement('glider', [0,2,b1axisy],{name:' '});
  x2 = board.createElement('point', [function(){return x1.X()-s.X();},0],{style:7,name:'a'});
+
  y2 = board.createElement('point', [function(){return y1.Y()-s.X();},0],{style:7,name:'a'});
  x3 = board.createElement('point', [function(){return x1.X()+s.X();},0],{style:7,name:' '});
+
  y3 = board.createElement('point', [function(){return y1.Y()+s.X();},0],{style:7,name:' '});
  y1 = board.createElement('point', [function(){return x1.X();},function(){return f(x1.X());}],{style:7,name:'f(a)'});
+
/*
 +
  x1 = board.createElement('point', [function(){return y1.Y();},function(){return f(x1.X());}],{style:7,name:'f(a)'});
 
  y2 = board.createElement('point', [function(){return x2.X();},function(){return f(x2.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:' '});
 
  y3 = board.createElement('point', [function(){return x3.X();},function(){return f(x3.X());}],{style:7,name:' '});
Line 76: Line 77:
 
  h3 = board.createElement('curve', [function(t){return t},function(t){return y3.Y();}],  
 
  h3 = board.createElement('curve', [function(t){return t},function(t){return y3.Y();}],  
 
               {strokeColor:'gray',dash:2,strokeWidth:1});
 
               {strokeColor:'gray',dash:2,strokeWidth:1});
 +
*/
 
</source>
 
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]

Revision as of 18:00, 10 January 2009

References

The underlying JavaScript source code

 board = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 250, unitX: 50, unitY: 50});
 b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
 b1axisy = board.createElement('axis', [[0,0], [0,1]], {});

 var f = function(x) {
       if (x<1) {
          return 0.5*x*x;
       } else {
         return x+1;
       }
      };
 graph = board.createElement('curve', ['x',f, 'x'], {curveType:'graph',strokeColor:'#00ff00'});

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

 y1 = board.createElement('glider', [0,2,b1axisy],{name:' '});
 y2 = board.createElement('point', [function(){return y1.Y()-s.X();},0],{style:7,name:'a'});
 y3 = board.createElement('point', [function(){return y1.Y()+s.X();},0],{style:7,name:' '});
/*
 x1 = board.createElement('point', [function(){return y1.Y();},function(){return f(x1.X());}],{style:7,name:'f(a)'});
 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:' '});
 v2 = board.createElement('line', [x2,y2],{strokeColor:'gray',dash:2,strokeWidth:1});
 v3 = board.createElement('line', [x3,y3],{strokeColor:'gray',dash:2,strokeWidth:1});

 h1 = board.createElement('curve', [function(t){return t},function(t){return y1.Y();}], 
              {strokeColor:'gray',dash:2,strokeWidth:1});
 h2 = board.createElement('curve', [function(t){return t},function(t){return y2.Y();}], 
              {strokeColor:'gray',dash:2,strokeWidth:1});
 h3 = board.createElement('curve', [function(t){return t},function(t){return y3.Y();}], 
              {strokeColor:'gray',dash:2,strokeWidth:1});
*/