JSXGraph logo
JSXGraph
JSXGraph share

Share

Conic sections in polar form
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/conic-sections-in-polar-form" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Conic sections in polar form" 
    allowfullscreen
></iframe>
This code has to
Curve term: <span id="output"></span>

<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 4.0 International License.
    https://creativecommons.org/licenses/by/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    const board = JXG.JSXGraph.initBoard(BOARDID, {
        axis: true,
        boundingbox: [-12, 10, 12, -10]
    });
    
    var p = board.create('slider', [
        [2, 8],
        [6, 8],
        [0, 3, 6]
    ], {
        name: 'p'
    });
    
    var eps = board.create('slider', [
        [2, 7],
        [6, 7],
        [-6, 0.5, 6]
    ], {
        name: '&epsilon;'
    });
    
    var len = board.create('slider', [
        [2, 6],
        [6, 6],
        [0, 3, 6]
    ], {
        name: 'len'
    });
    
    var rho = board.create('slider', [
        [2, 5],
        [6, 5],
        [0, 0, 2 * Math.PI]
    ], {
        name: '&rho;'
    });
    
    var f = board.create('curve',
        [function(phi) {
                return p.Value() / (1 - eps.Value() * Math.cos(phi + rho.Value()));
            },
            [1, 0], 0,
            function() {
                return len.Value() * Math.PI
            }
        ], {
            curveType: 'polar',
            strokewidth: 2,
            strokeColor: '#CA7291'
        }
    );
    
    // Show tangent:
    var q = board.create('glider', [f], {
        style: 6,
        name: 'G'
    });
    board.create('tangent', [q], {
        dash: 3
    });
    
    // Show the curve term
    board.on('update', function() {
        var _p = (p.Value()).toFixed(1),
     _eps = (eps.Value()).toFixed(1),
    _rho = (rho.Value()).toFixed(1);
    
        document.getElementById('output').innerHTML =  `r = ${_p} / (1 - (${_eps})*cos(&phi;+${_rho})`;
    });
    
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution 4.0 International License.
https://creativecommons.org/licenses/by/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!

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

var p = board.create('slider', [
    [2, 8],
    [6, 8],
    [0, 3, 6]
], {
    name: 'p'
});

var eps = board.create('slider', [
    [2, 7],
    [6, 7],
    [-6, 0.5, 6]
], {
    name: '&epsilon;'
});

var len = board.create('slider', [
    [2, 6],
    [6, 6],
    [0, 3, 6]
], {
    name: 'len'
});

var rho = board.create('slider', [
    [2, 5],
    [6, 5],
    [0, 0, 2 * Math.PI]
], {
    name: '&rho;'
});

var f = board.create('curve',
    [function(phi) {
            return p.Value() / (1 - eps.Value() * Math.cos(phi + rho.Value()));
        },
        [1, 0], 0,
        function() {
            return len.Value() * Math.PI
        }
    ], {
        curveType: 'polar',
        strokewidth: 2,
        strokeColor: '#CA7291'
    }
);

// Show tangent:
var q = board.create('glider', [f], {
    style: 6,
    name: 'G'
});
board.create('tangent', [q], {
    dash: 3
});

// Show the curve term
board.on('update', function() {
    var _p = (p.Value()).toFixed(1),
 _eps = (eps.Value()).toFixed(1),
_rho = (rho.Value()).toFixed(1);

    document.getElementById('output').innerHTML =  `r = ${_p} / (1 - (${_eps})*cos(&phi;+${_rho})`;
});

Conic sections in polar form

Conic sections can also be defined as curves in polar form. The equation of the curve is $$ r = p_1−\varepsilon\cdot \cos(\varphi + \rho) $$ The actual curve term is displayed in an HTML span using [ES6 template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals).
Curve term:
Curve term: <span id="output"></span>
// Define the id of your board in BOARDID

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

var p = board.create('slider', [
    [2, 8],
    [6, 8],
    [0, 3, 6]
], {
    name: 'p'
});

var eps = board.create('slider', [
    [2, 7],
    [6, 7],
    [-6, 0.5, 6]
], {
    name: 'ε'
});

var len = board.create('slider', [
    [2, 6],
    [6, 6],
    [0, 3, 6]
], {
    name: 'len'
});

var rho = board.create('slider', [
    [2, 5],
    [6, 5],
    [0, 0, 2 * Math.PI]
], {
    name: 'ρ'
});

var f = board.create('curve',
    [function(phi) {
            return p.Value() / (1 - eps.Value() * Math.cos(phi + rho.Value()));
        },
        [1, 0], 0,
        function() {
            return len.Value() * Math.PI
        }
    ], {
        curveType: 'polar',
        strokewidth: 2,
        strokeColor: '#CA7291'
    }
);

// Show tangent:
var q = board.create('glider', [f], {
    style: 6,
    name: 'G'
});
board.create('tangent', [q], {
    dash: 3
});

// Show the curve term
board.on('update', function() {
    var _p = (p.Value()).toFixed(1),
 _eps = (eps.Value()).toFixed(1),
_rho = (rho.Value()).toFixed(1);

    document.getElementById('output').innerHTML =  `r = ${_p} / (1 - (${_eps})*cos(φ+${_rho})`;
});

license

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