JSXGraph logo
JSXGraph
JSXGraph share

Share

3D curve
QR code
<iframe 
    src="https://jsxgraph.org/share/iframe/3d-curve" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: 3D curve" 
    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 not licensed.
    */
    
    const BOARDID = 'board-0';

    var board = JXG.JSXGraph.initBoard(BOARDID, {
        boundingbox: [-8, 8, 8, -8],
        keepaspectratio: false,
        axis: false
    });
    
    var view = board.create('view3d',
        [
            [-6, -3],
            [8, 8],
            [
                [-5, 5],
                [-5, 5],
                [-5, 5]
            ]
        ], {
            xPlaneRear: {
                visible: false
            },
            yPlaneRear: {
                visible: false
            },
            zPlaneRear: {
                fillColor: 'blue'
            }
        });
    
    var curve = view.create('curve3d', [
        (t) => (2 + Math.cos(3 * t)) * Math.cos(2 * t),
        (t) => (2 + Math.cos(3 * t)) * Math.sin(2 * t),
        (t) => Math.sin(3 * t),
        [-Math.PI, Math.PI]
    ], {
        strokeWidth: 4
    });
 </script> 
/*
This example is not licensed.
*/

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

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

var view = board.create('view3d',
    [
        [-6, -3],
        [8, 8],
        [
            [-5, 5],
            [-5, 5],
            [-5, 5]
        ]
    ], {
        xPlaneRear: {
            visible: false
        },
        yPlaneRear: {
            visible: false
        },
        zPlaneRear: {
            fillColor: 'blue'
        }
    });

var curve = view.create('curve3d', [
    (t) => (2 + Math.cos(3 * t)) * Math.cos(2 * t),
    (t) => (2 + Math.cos(3 * t)) * Math.sin(2 * t),
    (t) => Math.sin(3 * t),
    [-Math.PI, Math.PI]
], {
    strokeWidth: 4
});
<jsxgraph width="100%" aspect-ratio="1 / 1" title="3D curve" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is not licensed.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, {
       boundingbox: [-8, 8, 8, -8],
       keepaspectratio: false,
       axis: false
   });
   
   var view = board.create('view3d',
       [
           [-6, -3],
           [8, 8],
           [
               [-5, 5],
               [-5, 5],
               [-5, 5]
           ]
       ], {
           xPlaneRear: {
               visible: false
           },
           yPlaneRear: {
               visible: false
           },
           zPlaneRear: {
               fillColor: 'blue'
           }
       });
   
   var curve = view.create('curve3d', [
       (t) => (2 + Math.cos(3 * t)) * Math.cos(2 * t),
       (t) => (2 + Math.cos(3 * t)) * Math.sin(2 * t),
       (t) => Math.sin(3 * t),
       [-Math.PI, Math.PI]
   ], {
       strokeWidth: 4
   });
</jsxgraph>

3D curve

In this example, the function $$ f: {\mathbb R} \to {\mathbb R}^3, \; t \mapsto \begin{pmatrix} (2 + \cos(3t))\cos(2t)\\ (2 + \cos(3t))\sin(2t)\\ \sin(3t) \end{pmatrix} $$ is plotted.
// Define the id of your board in BOARDID

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

var view = board.create('view3d',
    [
        [-6, -3],
        [8, 8],
        [
            [-5, 5],
            [-5, 5],
            [-5, 5]
        ]
    ], {
        xPlaneRear: {
            visible: false
        },
        yPlaneRear: {
            visible: false
        },
        zPlaneRear: {
            fillColor: 'blue'
        }
    });

var curve = view.create('curve3d', [
    (t) => (2 + Math.cos(3 * t)) * Math.cos(2 * t),
    (t) => (2 + Math.cos(3 * t)) * Math.sin(2 * t),
    (t) => Math.sin(3 * t),
    [-Math.PI, Math.PI]
], {
    strokeWidth: 4
});

This example is not licensed.