Difference between revisions of "Reuleaux pentagon"

From JSXGraph Wiki
Jump to navigationJump to search
Line 3: Line 3:
 
<script type="text/javascript" src="/~alfred/jsxgraph/trunk/src/Roulette.js"></script>
 
<script type="text/javascript" src="/~alfred/jsxgraph/trunk/src/Roulette.js"></script>
 
<form>
 
<form>
<input type="button" value="start" onclick="rol.start(); rol3.start();">
+
<input type="button" value="start" onclick="rol5.start(); rol3.start();">
<input type="button" value="stop" onclick="rol.stop(); rol3.stop();">
+
<input type="button" value="stop" onclick="rol5.stop(); rol3.stop();">
 
<input type="button" value="one step" onclick="rol.rolling()">
 
<input type="button" value="one step" onclick="rol.rolling()">
 
</form></html>
 
</form></html>
Line 34: Line 34:
 
brd.unsuspendUpdate();
 
brd.unsuspendUpdate();
  
var rol = JXG.Math.Numerics.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/90, -1, 10, [A,B]);  
+
var rol5 = JXG.Math.Numerics.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/90, -1, 10, [A,B]);  
 
var rol3 = JXG.Math.Numerics.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/90, 1, 10, [C,D]);  
 
var rol3 = JXG.Math.Numerics.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/90, 1, 10, [C,D]);  
 +
var rollIt = function() {
 +
                rol5.rolling();
 +
                rol3.rolling();
 +
};
 +
var interval;
 +
var start = function() {
 +
              interval = setInterval(rollIt,10);
 +
};
 +
var stop = function() {
 +
              clearInterval(interval);
 +
}
 
</jsxgraph>
 
</jsxgraph>
  

Revision as of 21:45, 3 October 2010

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,7,5,-3]});
brd.suspendUpdate();
// Pentagon
var A = brd.create('point',[-2,-2]);
var B = brd.create('point',[2,-2]);
var pol5 = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});

// Triangle
var C = brd.create('point',[-2,-2]);
var D = brd.create('point',[C.X()+3/5*(1+Math.sqrt(5))*0.5*A.Dist(B), C.Y()]);
var pol3 = brd.create('regularpolygon',[C,D,3], {withLines:false, fillColor:'#e8501f', highlightFillColor:'#e8501f', fillOpacity:0.0});

// Heptagon
var E = brd.create('point',[-2,-2]);
var F = brd.create('point',[E.X()+7/5*A.Dist(pol5.vertices[2]), E.Y()]);
var pol7 = brd.create('regularpolygon',[E,F,7], {withLines:false, fillColor:'#e8501f', highlightFillColor:'#e8501f', fillOpacity:0.0});

var reuleauxHeptagon = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol7.vertices, 7), 
       {color:'#e8501f', highlightFillColor:'#e8501f'});
var reuleauxPentagon = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol5.vertices, 5), 
       {color:'#093083', highlightFillColor:'#093083'});
var reuleauxTriangle = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol3.vertices, 3), 
       {color:'#e8501f', highlightFillColor:'#e8501f'});
brd.unsuspendUpdate();

//var rol = JXG.Math.Numerics.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/90, -1, 10, [A,B])(); 
var rol3 = JXG.Math.Numerics.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/90, 1, 10, [C,D])();