Rolling circle on cosine: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 40: | Line 40: | ||
===The underlying JavaScript code=== | ===The underlying JavaScript code=== | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-1,5,20,-1], keepaspectratio:true}); | |||
brd.suspendUpdate(); | |||
// Line | |||
var line = brd.create('curve', [function(t) { return t;}, function(t){ return 0.5*Math.cos(t);}], | |||
{strokeWidth:6, strokeColor:'green'}); | |||
// Circle | |||
var P = brd.create('point',[0,0.5],{name:'P', trace:false}); | |||
var C = brd.create('point',[0,1],{name:'C'}); | |||
var circle = brd.create('curve',[ | |||
function(t){var d = P.Dist(C), | |||
beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P); | |||
t += beta; | |||
return C.X()+d*Math.cos(t); | |||
}, | |||
function(t){var d = P.Dist(C), | |||
beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P); | |||
t += beta; | |||
return C.Y()+d*Math.sin(t); | |||
}, | |||
0,2*Math.PI], | |||
{strokeWidth:6, strokeColor:'green'}); | |||
// Point on circle | |||
var B = brd.create('glider',[0,1.5,circle],{name:'B', color:'blue',trace:true}); | |||
brd.create('segment',[C,B],{color:'black'}); | |||
brd.unsuspendUpdate(); | |||
var rol = JXG.Math.Numerics.createRoulette(line, circle, 0, Math.PI/18, 1, 150, [C,P,B]); | |||
</source> | </source> | ||
Revision as of 14:53, 8 October 2010
The underlying JavaScript code
var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-1,5,20,-1], keepaspectratio:true});
brd.suspendUpdate();
// Line
var line = brd.create('curve', [function(t) { return t;}, function(t){ return 0.5*Math.cos(t);}],
{strokeWidth:6, strokeColor:'green'});
// Circle
var P = brd.create('point',[0,0.5],{name:'P', trace:false});
var C = brd.create('point',[0,1],{name:'C'});
var circle = brd.create('curve',[
function(t){var d = P.Dist(C),
beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P);
t += beta;
return C.X()+d*Math.cos(t);
},
function(t){var d = P.Dist(C),
beta = JXG.Math.Geometry.rad([C.X()+1,C.Y()],C,P);
t += beta;
return C.Y()+d*Math.sin(t);
},
0,2*Math.PI],
{strokeWidth:6, strokeColor:'green'});
// Point on circle
var B = brd.create('glider',[0,1.5,circle],{name:'B', color:'blue',trace:true});
brd.create('segment',[C,B],{color:'black'});
brd.unsuspendUpdate();
var rol = JXG.Math.Numerics.createRoulette(line, circle, 0, Math.PI/18, 1, 150, [C,P,B]);