Circle approximation: Difference between revisions

From JSXGraph Wiki
(var i;)
No edit summary
Line 6: Line 6:
var p1 = brd.createElement('point',[2,0]);
var p1 = brd.createElement('point',[2,0]);
var circ = brd.createElement('circle',[p0,p1]);
var circ = brd.createElement('circle',[p0,p1]);
var rot = brd.createElement('transform', [function() {return Math.PI*2.0/n.Value();},p0], {type:'rotate'});  // angle, rotation center
var ptmp = brd.createElement('point',[0,0],{visible:false,withLabel:false});
var c = brd.createElement('circle',[[],[]]);


var c = brd.createElement('circle',[[],[]]);
c.updateDataArray = function() {
c.updateDataArray = function() {
 
  var i;
  this.dataX = [p1.X()];
  this.dataY = [p1.Y()];
  ptmp.setPosition(JXG.COORDS_BY_USER,p1.X(),p1.Y());
  for (i=0;i<n.Value();i++) {
    rot.applyOnce(ptmp);
    this.dataX.push(ptmp.X()];
    this.dataY.push(ptmp.Y());
  }
}
}
</jsxgraph>
</jsxgraph>

Revision as of 09:12, 24 June 2009

The underlying JavaScript code