Rolling Reuleaux triangle

From JSXGraph Wiki
Revision as of 14:50, 8 October 2010 by A WASSERMANN (talk | contribs)

The underlying JavaScript code

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

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

var line = brd.create('curve',[function(t){return t;}, function(t){return -2;}], 
                {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
var reuleauxTriangle = brd.create('curve', JXG.Math.Numerics.reuleauxPolygon(pol3.vertices, 3), 
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
var S = brd.create('point', [
            function(){return (pol3.vertices[0].X()+pol3.vertices[1].X()+pol3.vertices[2].X())/3; },
            function(){return (pol3.vertices[0].Y()+pol3.vertices[1].Y()+pol3.vertices[2].Y())/3; }],
            {strokeColor:'#703545', fillColor:'#703545', highlightFillColor:'#703545', name:'S', trace:true});

brd.unsuspendUpdate();
var rol3 = JXG.Math.Numerics.createRoulette(line, reuleauxTriangle, -2, Math.PI/90, 1, 50, [A,B]);