Difference between revisions of "Trochoid"

From JSXGraph Wiki
Jump to: navigation, search
Line 14: Line 14:
 
  board.createElement('axis', [[0,0],[1,0]]);
 
  board.createElement('axis', [[0,0],[1,0]]);
 
  board.createElement('axis', [[0,0],[0,1]]);
 
  board.createElement('axis', [[0,0],[0,1]]);
  var a = board.createElement('slider', [[1,-1],[8,-1],[-5,1,5]], {style:6});
+
  var a = board.createElement('slider', [[1,-1],[8,-1],[-5,1,5]], {style:6,name:'a'});
  var b = board.createElement('slider', [[1,-2],[8,-2],[-5,1,5]], {style:6});
+
  var b = board.createElement('slider', [[1,-2],[8,-2],[-5,1,5]], {style:6,name:'b'});
 
  var x = function(phi) { return a.Value()*phi-b.Value()*Math.sin(phi); }
 
  var x = function(phi) { return a.Value()*phi-b.Value()*Math.sin(phi); }
 
  var y = function(phi) { return a.Value()-b.Value()*Math.cos(phi); }
 
  var y = function(phi) { return a.Value()-b.Value()*Math.cos(phi); }
Line 45: Line 45:
 
  board.createElement('axis', [[0,0],[1,0]]);
 
  board.createElement('axis', [[0,0],[1,0]]);
 
  board.createElement('axis', [[0,0],[0,1]]);
 
  board.createElement('axis', [[0,0],[0,1]]);
  var a = board.createElement('slider', [[1,-1],[8,-1],[-5,1,5]], {style:6});
+
  var a = board.createElement('slider', [[1,-1],[8,-1],[-5,1,5]], {style:6,name:'a'});
  var b = board.createElement('slider', [[1,-2],[8,-2],[-5,1,5]], {style:6});
+
  var b = board.createElement('slider', [[1,-2],[8,-2],[-5,1,5]], {style:6,name:'b'});
 
  var x = function(phi) { return a.Value()*phi-b.Value()*Math.sin(phi); }
 
  var x = function(phi) { return a.Value()*phi-b.Value()*Math.sin(phi); }
 
  var y = function(phi) { return a.Value()-b.Value()*Math.cos(phi); }
 
  var y = function(phi) { return a.Value()-b.Value()*Math.cos(phi); }

Revision as of 22:08, 7 April 2009

The Trochoid curve (blue) and its dual curve (red). The equation of the trochoid is

[math]x = a\phi-b\sin(\phi)[/math]
[math]y = a-b\cos(\phi)[/math]

References

The underlying JavaScript code

This is an example where jQuery is used.

<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jquery.min.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<div id="jsxgbox" class="jxgbox" style="width:500px; height:500px;"></div>
<script language="JavaScript"> 			
 board = JXG.JSXGraph.initBoard('jsxgbox', {originX: 250, originY: 250, unitX: 25, unitY: 25});
 board.suspendUpdate();
 board.createElement('axis', [[0,0],[1,0]]);
 board.createElement('axis', [[0,0],[0,1]]);
 var a = board.createElement('slider', [[1,-1],[8,-1],[-5,1,5]], {style:6,name:'a'});
 var b = board.createElement('slider', [[1,-2],[8,-2],[-5,1,5]], {style:6,name:'b'});
 var x = function(phi) { return a.Value()*phi-b.Value()*Math.sin(phi); }
 var y = function(phi) { return a.Value()-b.Value()*Math.cos(phi); }
 var c1 = board.createElement('curve', [x,y,-Math.PI*4,Math.PI*4],{strokeWidth:3});
 
 var dualCurve = function(x,y,board) {
    var X = function(phi) { return board.D(y)(phi)/(y(phi)*board.D(x)(phi)-x(phi)*board.D(y)(phi)); }
    var Y = function(phi) { return board.D(x)(phi)/(x(phi)*board.D(y)(phi)-y(phi)*board.D(x)(phi)); }
    return [X,Y];
    }
 var dual = dualCurve(x,y,board);
 var c2 = board.createElement('curve', [dual[0],dual[1],-Math.PI*1,Math.PI*1],{strokeWidth:3, strokeColor:'red'});
 board.unsuspendUpdate();
</script>