Rolling Reuleaux triangle: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(4 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/Roulette.js"></script>
<form>
<form>
<input type="button" value="start" onclick="rol3.start();">
<input type="button" value="start" onclick="rol3.start();">
Line 21: Line 19:
var line = brd.create('curve',[function(t){return t;}, function(t){return -2;}],  
var line = brd.create('curve',[function(t){return t;}, function(t){return -2;}],  
                 {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
                 {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
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:'#ad5544', highlightFillColor:'#ad5544'});
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
var S = brd.create('point', [
var S = brd.create('point', [
Line 29: Line 27:


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


Line 46: Line 44:
var line = brd.create('curve',[function(t){return t;}, function(t){return -2;}],  
var line = brd.create('curve',[function(t){return t;}, function(t){return -2;}],  
                 {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
                 {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#d6bb55', highlightFillColor:'#d6bb55'});
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:'#ad5544', highlightFillColor:'#ad5544'});
       {strokeWidth:6, strokeColor:'#d66d55', fillColor:'#ad5544', highlightFillColor:'#ad5544'});
var S = brd.create('point', [
var S = brd.create('point', [
Line 54: Line 52:


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



Latest revision as of 15:53, 20 February 2013

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.Geometry.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 = brd.createRoulette(line, reuleauxTriangle, -2, Math.PI/90, 1, 50, [A,B]);