JSXGraph logo
JSXGraph
JSXGraph share

Share

Rolling circle on cosine
QR code
<iframe 
    src="https://jsxgraph.org/share/iframe/rolling-circle-on-cosine" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Rolling circle on cosine" 
    allowfullscreen
></iframe>
This code has to
<input type="button" value="start" onclick="rol.start()">
<input type="button" value="stop" onclick="rol.stop()">
<input type="button" value="one step" onclick="rol.rolling()">

<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: [-1, 5, 20, -1], keepaspectratio: true });
    board.suspendUpdate();
    
    // Line
    var line = board.create('curve', [function(t) { return t; }, function(t) { return 0.5 * Math.cos(t); }], { strokeWidth: 6, strokeColor: 'green' });
    
    // Circle
    var P = board.create('point', [0, 0.5], { name: 'P', trace: false });
    var C = board.create('point', [0, 1], { name: 'C' });
    var circle = board.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 = board.create('glider', [0, 1.5, circle], { name: 'B', color: 'blue', trace: true });
    board.create('segment', [C, B], { color: 'black' });
    board.unsuspendUpdate();
    var rol = board.createRoulette(line, circle, 0, Math.PI / 18, 1, 150, [C, P, B]);
 </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: [-1, 5, 20, -1], keepaspectratio: true });
board.suspendUpdate();

// Line
var line = board.create('curve', [function(t) { return t; }, function(t) { return 0.5 * Math.cos(t); }], { strokeWidth: 6, strokeColor: 'green' });

// Circle
var P = board.create('point', [0, 0.5], { name: 'P', trace: false });
var C = board.create('point', [0, 1], { name: 'C' });
var circle = board.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 = board.create('glider', [0, 1.5, circle], { name: 'B', color: 'blue', trace: true });
board.create('segment', [C, B], { color: 'black' });
board.unsuspendUpdate();
var rol = board.createRoulette(line, circle, 0, Math.PI / 18, 1, 150, [C, P, B]);

Rolling circle on cosine

This code sets up a rolling circle along a green cosine-like line. A fixed point $C$ and a movable point $P$ define the smaller green circle. A glider point $B$ moves on that circle and leaves a visible trace while connected to $C$ by a segment. The smaller circle then rolls along the line, generating the roulette curve. **AI generated desctiption**
<input type="button" value="start" onclick="rol.start()">
<input type="button" value="stop" onclick="rol.stop()">
<input type="button" value="one step" onclick="rol.rolling()">
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-1, 5, 20, -1], keepaspectratio: true });
board.suspendUpdate();

// Line
var line = board.create('curve', [function(t) { return t; }, function(t) { return 0.5 * Math.cos(t); }], { strokeWidth: 6, strokeColor: 'green' });

// Circle
var P = board.create('point', [0, 0.5], { name: 'P', trace: false });
var C = board.create('point', [0, 1], { name: 'C' });
var circle = board.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 = board.create('glider', [0, 1.5, circle], { name: 'B', color: 'blue', trace: true });
board.create('segment', [C, B], { color: 'black' });
board.unsuspendUpdate();
var rol = board.createRoulette(line, circle, 0, Math.PI / 18, 1, 150, [C, P, B]);

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.