Restrict points to limited area: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 4: Line 4:
var B = brd.create('point', [-3, 2], {name:'B'});
var B = brd.create('point', [-3, 2], {name:'B'});
var C = brd.create('point', [ 3, 0], {name:'C'});
var C = brd.create('point', [ 3, 0], {name:'C'});
 
/*
brd.on('update', function() {
brd.on('update', function() {
   var list = [A, B, C], i;
   var list = [A, B, C], i;
Line 12: Line 12:
   }
   }
  });
  });
*/
A.on('update', function() {
  var list = [A, B, C], i;
      A.moveTo([Math.min(0, A.X()), Math.min(0, A.Y())]);
});
</jsxgraph>
</jsxgraph>



Revision as of 09:43, 18 June 2013

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,5,5,-5], axis:true});
var P0 = brd.create('point', [-4,-1], {name:'', face:'[]'});
var P1 = brd.create('point', [4,-1], {name:'', face:'[]'});
var li = brd.create('line', [P0,P1]);
var A = brd.create('glider', [0,-1,li], {name:'A'});
var B = brd.create('glider', [-3,-1,li], {name:'B'});
var C = brd.create('glider', [ 3,-1,li], {name:'C'});

brd.on('update', function() {
   var list = [A, B, C], i;
 
   for (i=

 });