Circle with ticks: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 12: Line 12:
         r = circ.Radius(),
         r = circ.Radius(),
         i,  
         i,  
        ticklen = 0.3,
         steps = 20,
         steps = 20,
        d = ticklen * 0.5,
         alpha = 2 * Math.PI / steps;
         alpha = 2 * Math.PI / steps;


Line 18: Line 20:
     this.dataY = [];
     this.dataY = [];
     for (i = 0; i < steps; i++) {
     for (i = 0; i < steps; i++) {
         this.dataX.push( cx + 0.95 * r * Math.cos(i * alpha) );
         this.dataX.push( cx + (r - d)* Math.cos(i * alpha) );
         this.dataY.push( cy + 0.95 * r * Math.sin(i * alpha) );
         this.dataY.push( cy + (r - d) * Math.sin(i * alpha) );
         this.dataX.push( cx + 1.05 * r * Math.cos(i * alpha) );
         this.dataX.push( cx + (r + d) * Math.cos(i * alpha) );
         this.dataY.push( cy + 1.05 * r * Math.sin(i * alpha) );
         this.dataY.push( cy + (r + d) * Math.sin(i * alpha) );
         this.dataX.push( NaN );
         this.dataX.push( NaN );
         this.dataY.push( NaN );
         this.dataY.push( NaN );
     }
     }
 
};
};
brd.update();


</jsxgraph>
</jsxgraph>

Revision as of 22:00, 24 March 2014

The underlying JavaScript code