Reuleaux pentagon: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(93 intermediate revisions by the same user not shown)
Line 1: Line 1:
<jsxgraph width="600" height="600">
<html>
JXG.Options.layer.polygon = 8;
<form>
JXG.Options.layer.sector = 8;
<input type="button" value="start" onclick="start();">
<input type="button" value="stop" onclick="stop();">
<input type="button" value="one step" onclick="rol5.rolling();rol3.rolling();">
</form></html>
 
<jsxgraph width="600" height="600" box="jxgbox">
var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,7,5,-3]});
brd.renderer.container.style.backgroundColor = '#3d1c24';         // background color board


var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,5,5,-5]});
brd.suspendUpdate();
brd.suspendUpdate();
// Pentagon
// Pentagon
var A = brd.create('point',[-2,-2]);
var A = brd.create('point',[-2,-2]);
var B = brd.create('point',[2,-2]);
var B = brd.create('point',[2,-2]);
var pol = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'none',, highlightFillColor:'none'});
var pol5 = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
for (var i=0;i<5;i++) pol5.vertices[i].setProperty({color:'#3d1c24'});
 
var diagPentagon = (1+Math.sqrt(5))*0.5*A.Dist(B);


var reuleauxPentagon = brd.create('curve',[
// Triangle
      function(t) {
        var p = pol.vertices;
        var d = p[0].Dist(p[2]);
        var t1 = (t%(2*Math.PI) + 2*Math.PI) %(2*Math.PI);
        var n = Math.floor(t1 / (Math.PI*2.0/5.0))%5;
        if (isNaN(n)) return n;
        var beta = JXG.Math.Geometry.rad([p[n].X()+1,p[n].Y()],p[n],p[(n+2)%5]);
        t1 -= n*2*Math.PI/5.0;
        t1*=0.5;
        t1 += beta;
        return p[n].X()+d*Math.cos(t1);
      },
      function(t) {
        var p = pol.vertices;
        var d = p[0].Dist(p[2]);
        var t1 = (t%(2*Math.PI) + 2*Math.PI) %(2*Math.PI);
        var n = Math.floor(t1 / (Math.PI*2.0/5.0))%5;
        if (isNaN(n)) return n;
        var beta = JXG.Math.Geometry.rad([p[n].X()+1,p[n].Y()],p[n],p[(n+2)%5]);
        t1 -= n*2*Math.PI/5.0;
        t1*=0.5;
        t1 += beta;
        return p[n].Y()+d*Math.sin(t1);
      },
      0, 2*Math.PI],
      {color:'#093083', highlightFillColor:'#093083'});
     
/*
for (var i=0;i<5;i++) {
    brd.create('arc',[pol.vertices[i],pol.vertices[(i+2)%5],pol.vertices[(i+3)%5]],{strokeColor:'#093083'});
    brd.create('sector',[pol.vertices[i],pol.vertices[(i+2)%5],pol.vertices[(i+3)%5]],
          {fillColor:'#093083', highlightFillColor:'#093083', fillOpacity:1.0, highlightFillOpacity:1.0,
          strokeWidth:0});
}
*/
/*
var C = brd.create('point',[-2,-2]);
var C = brd.create('point',[-2,-2]);
var D = brd.create('point',[function(){
var D = brd.create('point',[C.X()+3/5*diagPentagon, C.Y()]);
                            var p = A.Dist(B);  
var pol3 = brd.create('regularpolygon',[C,D,3], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
                            return C.X()+3*(1+Math.sqrt(5))/2/5*p;
for (i=0;i<3;i++) pol3.vertices[i].setProperty({color:'#3d1c24'});
                            },
 
                            function(){
// Heptagon
                            return C.Y();
var E = brd.create('point',[-2,-2]);
                            }
 
                          ]);
//
var pol3 = brd.create('regularpolygon',[C,D,3], {withLines:false, fillColor:'#e8501f', highlightFillColor:'#e8501f'});
// Side length of the heptagon depending on the diagonal of the pentagon:
// r_7 = 7/5*r_5
var diagHeptagon = 7/5*diagPentagon;
// s_7 = r_7*sqrt(2)*sqrt(1-cos(pi/7)) (law of cosines)
var sideHeptagon = Math.sqrt(2*(1-Math.cos(Math.PI/7)))*diagHeptagon;
//  
var F = brd.create('point',[E.X()+sideHeptagon, E.Y()]);
var pol7 = brd.create('regularpolygon',[E,F,7], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
for (i=0;i<7;i++) pol7.vertices[i].setProperty({color:'#3d1c24'});


for (i=0;i<3;i++) {
// Create the Reuleauc curves
    brd.create('arc',[pol3.vertices[i],
var reuleauxHeptagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol7.vertices, 7),  
                      pol3.vertices[(i+1)%3],
      {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
                      pol3.vertices[(i+2)%3]],  
var reuleauxPentagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol5.vertices, 5),  
            {strokeColor:'#e8501f'});
      {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
    brd.create('sector',[pol3.vertices[i],
var reuleauxTriangle = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol3.vertices, 3),  
                      pol3.vertices[(i+1)%3],
      {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
                      pol3.vertices[(i+2)%3]],  
            {fillColor:'#e8501f', highlightFillColor:'#e8501f',fillOpacity:1.0, highlightFillOpacity:1.0,  
              strokeWidth:0});
}
*/
brd.unsuspendUpdate();
brd.unsuspendUpdate();


var rol5 = brd.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/45, 1, 50, [A,B,C,D]);
var rol3 = brd.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/45, -1, 50, [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>


===The underlying JavaScript code===
===The underlying JavaScript code===
<source lang="javascript">
<source lang="javascript">
JXG.Options.layer.polygon = 8;
var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,7,5,-3]});
JXG.Options.layer.sector = 8;
brd.renderer.container.style.backgroundColor = '#3d1c24';         // background color board


var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,5,5,-5]});
brd.suspendUpdate();
brd.suspendUpdate();
// Pentagon
var A = brd.create('point',[-2,-2]);
var A = brd.create('point',[-2,-2]);
var B = brd.create('point',[2,-2]);
var B = brd.create('point',[2,-2]);
var pol = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'#093083', highlightFillColor:'#093083'});
var pol5 = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
for (var i=0;i<5;i++) pol5.vertices[i].setProperty({color:'#3d1c24'});
 
var diagPentagon = (1+Math.sqrt(5))*0.5*A.Dist(B);


for (var i=0;i<5;i++) {
// Triangle
    brd.create('arc',[pol.vertices[i],pol.vertices[(i+2)%5],pol.vertices[(i+3)%5]],{strokeColor:'#093083'});
var C = brd.create('point',[-2,-2]);
    brd.create('sector',[pol.vertices[i],pol.vertices[(i+2)%5],pol.vertices[(i+3)%5]],
var D = brd.create('point',[C.X()+3/5*diagPentagon, C.Y()]);
          {fillColor:'#093083', highlightFillColor:'#093083', fillOpacity:1.0, highlightFillOpacity:1.0,
var pol3 = brd.create('regularpolygon',[C,D,3], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
          strokeWidth:0});
for (i=0;i<3;i++) pol3.vertices[i].setProperty({color:'#3d1c24'});
}


// Heptagon
var E = brd.create('point',[-2,-2]);


var C = brd.create('point',[-2,-2]);
//
var D = brd.create('point',[function(){
// Side length of the heptagon depending on the diagonal of the pentagon:
                            var p = A.Dist(B);
// r_7 = 7/5*r_5
                            return C.X()+3*(1+Math.sqrt(5))/2/5*p;
var diagHeptagon = 7/5*diagPentagon;
                            },
// s_7 = r_7*sqrt(2)*sqrt(1-cos(pi/7)) (law of cosines)
                            function(){
var sideHeptagon = Math.sqrt(2*(1-Math.cos(Math.PI/7)))*diagHeptagon;
                            return C.Y();
//  
                            }
var F = brd.create('point',[E.X()+sideHeptagon, E.Y()]);
                          ]);
var pol7 = brd.create('regularpolygon',[E,F,7], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
var pol3 = brd.create('regularpolygon',[C,D,3], {withLines:false, fillColor:'#e8501f', highlightFillColor:'#e8501f'});
for (i=0;i<7;i++) pol7.vertices[i].setProperty({color:'#3d1c24'});


for (i=0;i<3;i++) {
// Create the Reuleauc curves
    brd.create('arc',[pol3.vertices[i],
var reuleauxHeptagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol7.vertices, 7),  
                      pol3.vertices[(i+1)%3],
      {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
                      pol3.vertices[(i+2)%3]],  
var reuleauxPentagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol5.vertices, 5),  
            {strokeColor:'#e8501f'});
      {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
    brd.create('sector',[pol3.vertices[i],
var reuleauxTriangle = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol3.vertices, 3),  
                      pol3.vertices[(i+1)%3],
      {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
                      pol3.vertices[(i+2)%3]],  
            {fillColor:'#e8501f', highlightFillColor:'#e8501f',fillOpacity:1.0, highlightFillOpacity:1.0,  
              strokeWidth:0});
}
brd.unsuspendUpdate();
brd.unsuspendUpdate();


var rol5 = brd.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/45, 1, 50, [A,B,C,D]);
var rol3 = brd.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/45, -1, 50, [C,D]);
var rollIt = function() {
                rol5.rolling();
                rol3.rolling();
};
var interval;
var start = function() {
              interval = setInterval(rollIt,10);
};
var stop = function() {
              clearInterval(interval);
}
</source>
</source>


[[Category:Examples]]
[[Category:Examples]]
[[Category:Geometry]]
[[Category:Geometry]]
[[Category:Roulettes]]

Latest revision as of 15:50, 20 February 2013

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,7,5,-3]});
brd.renderer.container.style.backgroundColor = '#3d1c24';          // background color board

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});
for (var i=0;i<5;i++) pol5.vertices[i].setProperty({color:'#3d1c24'});

var diagPentagon = (1+Math.sqrt(5))*0.5*A.Dist(B);

// Triangle
var C = brd.create('point',[-2,-2]);
var D = brd.create('point',[C.X()+3/5*diagPentagon, C.Y()]);
var pol3 = brd.create('regularpolygon',[C,D,3], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
for (i=0;i<3;i++) pol3.vertices[i].setProperty({color:'#3d1c24'});

// Heptagon
var E = brd.create('point',[-2,-2]);

//
// Side length of the heptagon depending on the diagonal of the pentagon:
// r_7 = 7/5*r_5
var diagHeptagon = 7/5*diagPentagon;
// s_7 = r_7*sqrt(2)*sqrt(1-cos(pi/7)) (law of cosines)
var sideHeptagon = Math.sqrt(2*(1-Math.cos(Math.PI/7)))*diagHeptagon;
// 
var F = brd.create('point',[E.X()+sideHeptagon, E.Y()]);
var pol7 = brd.create('regularpolygon',[E,F,7], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
for (i=0;i<7;i++) pol7.vertices[i].setProperty({color:'#3d1c24'});

// Create the Reuleauc curves
var reuleauxHeptagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol7.vertices, 7), 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
var reuleauxPentagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol5.vertices, 5), 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
var reuleauxTriangle = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol3.vertices, 3), 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
brd.unsuspendUpdate();

var rol5 = brd.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/45, 1, 50, [A,B,C,D]); 
var rol3 = brd.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/45, -1, 50, [C,D]); 
var rollIt = function() {
                rol5.rolling();
                rol3.rolling();
};
var interval;
var start = function() {
              interval = setInterval(rollIt,10);
};
var stop = function() {
              clearInterval(interval);
}