JSXGraph logo
JSXGraph
JSXGraph share

Share

Trochoid
QR code
<iframe 
    src="https://www.jsxgraph.uni-bayreuth.de/share/iframe/trochoid" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Trochoid" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>

<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution ShareAlike 4.0 International License.
    https://creativecommons.org/licenses/by-sa/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-10, 10, 10, -10], axis: true, keepaspectratio: true });
    
    var D = JXG.Math.Numerics.D;
    var a = board.create('slider', [[1, -1], [8, -1], [-5, 1, 5]], { style: 6, name: 'a' });
    var b = board.create('slider', [[1, -2], [8, -2], [-5, 1, 5]], { style: 6, name: 'b' });
    
    var x = (phi) => a.Value() * phi - b.Value() * Math.sin(phi);
    var y = (phi) => a.Value() - b.Value() * Math.cos(phi);
    
    var c1 = board.create('curve', [x, y, -Math.PI * 4, Math.PI * 4], { strokeWidth: 3 });
    
    var dualCurve = function(x, y, board) {
        var X = (phi) => D(y)(phi) / (y(phi) * D(x)(phi) - x(phi) * D(y)(phi)),
            Y = (phi) => D(x)(phi) / (x(phi) * D(y)(phi) - y(phi) * D(x)(phi));
        return [X, Y];
    }
    var dual = dualCurve(x, y, board);
    var c2 = board.create('curve', [dual[0], dual[1], -Math.PI, Math.PI], {
        strokeWidth: 3,
        strokeColor: 'red'
    });
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID = 'your_div_id'; // Insert your id here!

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-10, 10, 10, -10], axis: true, keepaspectratio: true });

var D = JXG.Math.Numerics.D;
var a = board.create('slider', [[1, -1], [8, -1], [-5, 1, 5]], { style: 6, name: 'a' });
var b = board.create('slider', [[1, -2], [8, -2], [-5, 1, 5]], { style: 6, name: 'b' });

var x = (phi) => a.Value() * phi - b.Value() * Math.sin(phi);
var y = (phi) => a.Value() - b.Value() * Math.cos(phi);

var c1 = board.create('curve', [x, y, -Math.PI * 4, Math.PI * 4], { strokeWidth: 3 });

var dualCurve = function(x, y, board) {
    var X = (phi) => D(y)(phi) / (y(phi) * D(x)(phi) - x(phi) * D(y)(phi)),
        Y = (phi) => D(x)(phi) / (x(phi) * D(y)(phi) - y(phi) * D(x)(phi));
    return [X, Y];
}
var dual = dualCurve(x, y, board);
var c2 = board.create('curve', [dual[0], dual[1], -Math.PI, Math.PI], {
    strokeWidth: 3,
    strokeColor: 'red'
});
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Trochoid" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is licensed under a 
   Creative Commons Attribution ShareAlike 4.0 International License.
   https://creativecommons.org/licenses/by-sa/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-10, 10, 10, -10], axis: true, keepaspectratio: true });
   
   var D = JXG.Math.Numerics.D;
   var a = board.create('slider', [[1, -1], [8, -1], [-5, 1, 5]], { style: 6, name: 'a' });
   var b = board.create('slider', [[1, -2], [8, -2], [-5, 1, 5]], { style: 6, name: 'b' });
   
   var x = (phi) => a.Value() * phi - b.Value() * Math.sin(phi);
   var y = (phi) => a.Value() - b.Value() * Math.cos(phi);
   
   var c1 = board.create('curve', [x, y, -Math.PI * 4, Math.PI * 4], { strokeWidth: 3 });
   
   var dualCurve = function(x, y, board) {
       var X = (phi) => D(y)(phi) / (y(phi) * D(x)(phi) - x(phi) * D(y)(phi)),
           Y = (phi) => D(x)(phi) / (x(phi) * D(y)(phi) - y(phi) * D(x)(phi));
       return [X, Y];
   }
   var dual = dualCurve(x, y, board);
   var c2 = board.create('curve', [dual[0], dual[1], -Math.PI, Math.PI], {
       strokeWidth: 3,
       strokeColor: 'red'
   });
</jsxgraph>

Trochoid

The Trochoid curve (blue) and its dual curve (red). The equation of the trochoid is $$x = a\phi-b\sin(\phi)$$ $$y = a-b\cos(\phi)$$
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-10, 10, 10, -10], axis: true, keepaspectratio: true });

var D = JXG.Math.Numerics.D;
var a = board.create('slider', [[1, -1], [8, -1], [-5, 1, 5]], { style: 6, name: 'a' });
var b = board.create('slider', [[1, -2], [8, -2], [-5, 1, 5]], { style: 6, name: 'b' });

var x = (phi) => a.Value() * phi - b.Value() * Math.sin(phi);
var y = (phi) => a.Value() - b.Value() * Math.cos(phi);

var c1 = board.create('curve', [x, y, -Math.PI * 4, Math.PI * 4], { strokeWidth: 3 });

var dualCurve = function(x, y, board) {
    var X = (phi) => D(y)(phi) / (y(phi) * D(x)(phi) - x(phi) * D(y)(phi)),
        Y = (phi) => D(x)(phi) / (x(phi) * D(y)(phi) - y(phi) * D(x)(phi));
    return [X, Y];
}
var dual = dualCurve(x, y, board);
var c2 = board.create('curve', [dual[0], dual[1], -Math.PI, Math.PI], {
    strokeWidth: 3,
    strokeColor: 'red'
});

license

This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.