Segments with fixed length: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<jsxgraph width="400" height="400" box="box">
<jsxgraph width="400" height="400" box="box">
var brd = JXG.JSXGraph.initBoard('box', {axis:false, boundingbox: [-5, 5, 5, -5]}),
var brd = JXG.JSXGraph.initBoard('box', {axis:false, boundingbox: [-5, 5, 5, -5]}),
   p0 = brd.create('point', [-2,2]),
   p0 = brd.create('point', [-2,2], {withLabel:false}),
   p1 = brd.create('point', [0,2]),
   p1 = brd.create('point', [0,2], {withLabel:false}),
   p2 = brd.create('point', [-2,0]),
   p2 = brd.create('point', [-2,0], {withLabel:false}),
   p3 = brd.create('point', [0,0]),
   p3 = brd.create('point', [0,0], {withLabel:false}),
   p4 = brd.create('point', [-2,-2]),
   p4 = brd.create('point', [-2,-2], {withLabel:false}),
   p5 = brd.create('point', [0,-2]),
   p5 = brd.create('point', [0,-2], {withLabel:false}),
 
   seg1 = brd.create('segment', [p0, p1], {withLabel:true, name:'seg1: free'}), // free segment
   seg1 = brd.create('segment', [p0, p1], {withLabel:true, name:'seg1: free'}), // free segment
   seg2 = brd.create('segment', [p2, p3, 2], {withLabel:true, name:'length 2'}), // segment of length 2
   seg2 = brd.create('segment', [p2, p3, 2], {withLabel:true, name:'length 2'}), // segment of length 2
   seg3 = brd.create('segment', [p4, p5, function(){ return seg1.L();}], {withLabel:true, name:'length of seg1'}); // segment of length of seg1
   seg3 = brd.create('segment', [p4, p5, function(){ return seg1.L();}], {withLabel:true, name:'length of seg1'});  
 
  // segment has length of seg1
</jsxgraph>
</jsxgraph>


Line 16: Line 17:
<source lang="javascript">
<source lang="javascript">
var brd = JXG.JSXGraph.initBoard('box', {axis:false, boundingbox: [-5, 5, 5, -5]}),
var brd = JXG.JSXGraph.initBoard('box', {axis:false, boundingbox: [-5, 5, 5, -5]}),
   li = brd.create('line', [1,2,3]),
   p0 = brd.create('point', [-2,2], {withLabel:false}),
   ci = brd.create('circle', [[2,2],1]),
   p1 = brd.create('point', [0,2], {withLabel:false}),
   p0 = brd.create('point', [-2,0], {color:'blue'}),
   p2 = brd.create('point', [-2,0], {withLabel:false}),
   p = brd.create('point', [-2,-2], {attractors: [li,ci,p0], attractorDistance:0.2, snatchDistance: 2});
  p3 = brd.create('point', [0,0], {withLabel:false}),
   p4 = brd.create('point', [-2,-2], {withLabel:false}),
  p5 = brd.create('point', [0,-2], {withLabel:false}),
 
  seg1 = brd.create('segment', [p0, p1], {withLabel:true, name:'seg1: free'}), // free segment
  seg2 = brd.create('segment', [p2, p3, 2], {withLabel:true, name:'length 2'}), // segment of length 2
  seg3 = brd.create('segment', [p4, p5, function(){ return seg1.L();}], {withLabel:true, name:'length of seg1'});  
  // segment has length of seg1
</source>
</source>

Latest revision as of 10:58, 26 January 2012

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('box', {axis:false, boundingbox: [-5, 5, 5, -5]}),
   p0 = brd.create('point', [-2,2], {withLabel:false}),
   p1 = brd.create('point', [0,2], {withLabel:false}),
   p2 = brd.create('point', [-2,0], {withLabel:false}),
   p3 = brd.create('point', [0,0], {withLabel:false}),
   p4 = brd.create('point', [-2,-2], {withLabel:false}),
   p5 = brd.create('point', [0,-2], {withLabel:false}),

   seg1 = brd.create('segment', [p0, p1], {withLabel:true, name:'seg1: free'}), // free segment
   seg2 = brd.create('segment', [p2, p3, 2], {withLabel:true, name:'length 2'}), // segment of length 2
   seg3 = brd.create('segment', [p4, p5, function(){ return seg1.L();}], {withLabel:true, name:'length of seg1'}); 
   // segment has length of seg1