Difference between revisions of "Reuleaux pentagon"

From JSXGraph Wiki
Jump to navigationJump to search
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
<jsxgraph width="0" height="0" box="nix"></jsxgraph>
 
 
<html>
 
<html>
<script type="text/javascript" src="/~alfred/jsxgraph/trunk/src/Complex.js"></script>
 
<script type="text/javascript" src="/~alfred/jsxgraph/trunk/src/Roulette2.js"></script>
 
 
<form>
 
<form>
 
<input type="button" value="start" onclick="start();">
 
<input type="button" value="start" onclick="start();">
Line 19: Line 16:
 
var pol5 = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
 
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'});
 
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
 
// Triangle
 
var C = brd.create('point',[-2,-2]);
 
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 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});
 
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'});
 
for (i=0;i<3;i++) pol3.vertices[i].setProperty({color:'#3d1c24'});
Line 28: Line 27:
 
// Heptagon
 
// Heptagon
 
var E = brd.create('point',[-2,-2]);
 
var E = brd.create('point',[-2,-2]);
 +
 
//
 
//
 
// Side length of the heptagon depending on the diagonal of the pentagon:
 
// Side length of the heptagon depending on the diagonal of the pentagon:
 
// r_7 = 7/5*r_5
 
// 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)
 
// 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()+Math.sqrt(2*(1-Math.cos(2*Math.PI/7)))*7/5*A.Dist(pol5.vertices[2]), E.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 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<7;i++) pol7.vertices[i].setProperty({color:'#3d1c24'});
  
 
// Create the Reuleauc curves
 
// Create the Reuleauc curves
var reuleauxHeptagon = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol7.vertices, 7),  
+
var reuleauxHeptagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol7.vertices, 7),  
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
var reuleauxPentagon = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol5.vertices, 5),  
+
var reuleauxPentagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol5.vertices, 5),  
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
var reuleauxTriangle = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol3.vertices, 3),  
+
var reuleauxTriangle = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol3.vertices, 3),  
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
 
brd.unsuspendUpdate();
 
brd.unsuspendUpdate();
  
var rol5 = JXG.Math.Numerics.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/45, -1, 50, [A,B,C,D]);  
+
var rol5 = brd.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/45, 1, 50, [A,B,C,D]);  
var rol3 = JXG.Math.Numerics.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/45, 1, 50, [C,D]);  
+
var rol3 = brd.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/45, -1, 50, [C,D]);  
 
var rollIt = function() {
 
var rollIt = function() {
 
                 rol5.rolling();
 
                 rol5.rolling();
Line 72: Line 74:
 
var pol5 = brd.create('regularpolygon',[A,B,5], {withLines:false, fillColor:'none', highlightFillColor:'none', fillOpacity:0.0});
 
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'});
 
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
 
// Triangle
 
var C = brd.create('point',[-2,-2]);
 
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 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});
 
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'});
 
for (i=0;i<3;i++) pol3.vertices[i].setProperty({color:'#3d1c24'});
Line 81: Line 85:
 
// Heptagon
 
// Heptagon
 
var E = brd.create('point',[-2,-2]);
 
var E = brd.create('point',[-2,-2]);
var F = brd.create('point',[E.X()+7/5*A.Dist(pol5.vertices[2]), E.Y()]);
+
 
 +
//
 +
// 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});
 
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<7;i++) pol7.vertices[i].setProperty({color:'#3d1c24'});
  
 
// Create the Reuleauc curves
 
// Create the Reuleauc curves
var reuleauxHeptagon = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol7.vertices, 7),  
+
var reuleauxHeptagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol7.vertices, 7),  
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
var reuleauxPentagon = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol5.vertices, 5),  
+
var reuleauxPentagon = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol5.vertices, 5),  
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
var reuleauxTriangle = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol3.vertices, 3),  
+
var reuleauxTriangle = brd.create('curve', JXG.Math.Geometry.reuleauxPolygon(pol3.vertices, 3),  
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#703545', highlightFillColor:'#703545'});
 
brd.unsuspendUpdate();
 
brd.unsuspendUpdate();
  
var rol5 = JXG.Math.Numerics.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/90, -1, 10, [A,B,C,D]);  
+
var rol5 = brd.createRoulette(reuleauxHeptagon, reuleauxPentagon, 6*Math.PI/5, Math.PI/45, 1, 50, [A,B,C,D]);  
var rol3 = JXG.Math.Numerics.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/90, 1, 10, [C,D]);  
+
var rol3 = brd.createRoulette(reuleauxPentagon, reuleauxTriangle, 6*Math.PI/5, Math.PI/45, -1, 50, [C,D]);  
 
+
var rollIt = function() {
var letItRoll = function() {
+
                rol5.rolling();
              rol5.rolling();
+
                rol3.rolling();
              rol3.rolling();
 
 
};
 
};
 
var interval;
 
var interval;
 
var start = function() {
 
var start = function() {
               interval = setInterval(letItRoll,10);
+
               interval = setInterval(rollIt,10);
 
};
 
};
 
var stop = function() {
 
var stop = function() {

Latest revision as of 17: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);
}