JSXGraph logo
JSXGraph
JSXGraph share

Share

Dual lattice
QR code
<iframe 
    src="http://jsxgraph.org/share/iframe/dual-lattice" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Dual lattice" 
    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 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, {boundingbox: [-5, 5, 5, -5], axis:false});
    
    // Primal basis vectors
    var b1 = board.create('point', [4,0], {size:6, name:'b_1', color:'blue', snaptogrid: true}),
        b2 = board.create('point', [3,3], {size:6, name:'b_2', color:'blue', snaptogrid: true}),
        v1 = board.create('arrow', [[0,0], b1], {strokeColor: 'black', fixed: true}),   
        v2 = board.create('arrow', [[0,0], b2], {strokeColor: 'red', fixed: true}),
        w1, w2;
    
    
    // Plot lattice points
    for (let i = -5; i < 6; i++) {
        for (let j = -5; j < 6; j++) {
            if (!(i == 1 && j == 0) && !(i == 0 && j == 1)) { 
                board.create('point', [
                    () => i * b1.X() + j * b2.X(),
                    () => i * b1.Y() + j * b2.Y()
                ], {name:'', withLabel: false, size:2});
            }
        }
    }
    
    // Dual basis vectors
    w1 = board.create('arrow', [[0,0], function() {
                var num = b1.X() * b2.Y() - b2.X() * b1.Y();
                return [b2.Y() / num,  -b2.X() / num];
    }], {strokeColor: 'black', name:"b_1'", withLabel:true, label:{position:'rt'}});
    
    w2 = board.create('arrow', [[0,0], function() {
                var num = b1.X() * b2.Y() - b2.X() * b1.Y();
                return [-b1.Y() / num,  b1.X() / num];
    }], {strokeColor: 'red', name:"b_2'", withLabel:true, label:{position:'rt'}});
    
 </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, {boundingbox: [-5, 5, 5, -5], axis:false});

// Primal basis vectors
var b1 = board.create('point', [4,0], {size:6, name:'b_1', color:'blue', snaptogrid: true}),
    b2 = board.create('point', [3,3], {size:6, name:'b_2', color:'blue', snaptogrid: true}),
    v1 = board.create('arrow', [[0,0], b1], {strokeColor: 'black', fixed: true}),   
    v2 = board.create('arrow', [[0,0], b2], {strokeColor: 'red', fixed: true}),
    w1, w2;


// Plot lattice points
for (let i = -5; i < 6; i++) {
    for (let j = -5; j < 6; j++) {
        if (!(i == 1 && j == 0) && !(i == 0 && j == 1)) { 
            board.create('point', [
                () => i * b1.X() + j * b2.X(),
                () => i * b1.Y() + j * b2.Y()
            ], {name:'', withLabel: false, size:2});
        }
    }
}

// Dual basis vectors
w1 = board.create('arrow', [[0,0], function() {
            var num = b1.X() * b2.Y() - b2.X() * b1.Y();
            return [b2.Y() / num,  -b2.X() / num];
}], {strokeColor: 'black', name:"b_1'", withLabel:true, label:{position:'rt'}});

w2 = board.create('arrow', [[0,0], function() {
            var num = b1.X() * b2.Y() - b2.X() * b1.Y();
            return [-b1.Y() / num,  b1.X() / num];
}], {strokeColor: 'red', name:"b_2'", withLabel:true, label:{position:'rt'}});
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Dual lattice" 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 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 board = JXG.JSXGraph.initBoard(BOARDID, {boundingbox: [-5, 5, 5, -5], axis:false});
   
   // Primal basis vectors
   var b1 = board.create('point', [4,0], {size:6, name:'b_1', color:'blue', snaptogrid: true}),
       b2 = board.create('point', [3,3], {size:6, name:'b_2', color:'blue', snaptogrid: true}),
       v1 = board.create('arrow', [[0,0], b1], {strokeColor: 'black', fixed: true}),   
       v2 = board.create('arrow', [[0,0], b2], {strokeColor: 'red', fixed: true}),
       w1, w2;
   
   
   // Plot lattice points
   for (let i = -5; i < 6; i++) {
       for (let j = -5; j < 6; j++) {
           if (!(i == 1 && j == 0) && !(i == 0 && j == 1)) { 
               board.create('point', [
                   () => i * b1.X() + j * b2.X(),
                   () => i * b1.Y() + j * b2.Y()
               ], {name:'', withLabel: false, size:2});
           }
       }
   }
   
   // Dual basis vectors
   w1 = board.create('arrow', [[0,0], function() {
               var num = b1.X() * b2.Y() - b2.X() * b1.Y();
               return [b2.Y() / num,  -b2.X() / num];
   }], {strokeColor: 'black', name:"b_1'", withLabel:true, label:{position:'rt'}});
   
   w2 = board.create('arrow', [[0,0], function() {
               var num = b1.X() * b2.Y() - b2.X() * b1.Y();
               return [-b1.Y() / num,  b1.X() / num];
   }], {strokeColor: 'red', name:"b_2'", withLabel:true, label:{position:'rt'}});
   
</jsxgraph>

Dual lattice

// Define the id of your board in BOARDID

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

// Primal basis vectors
var b1 = board.create('point', [4,0], {size:6, name:'b_1', color:'blue', snaptogrid: true}),
    b2 = board.create('point', [3,3], {size:6, name:'b_2', color:'blue', snaptogrid: true}),
    v1 = board.create('arrow', [[0,0], b1], {strokeColor: 'black', fixed: true}),   
    v2 = board.create('arrow', [[0,0], b2], {strokeColor: 'red', fixed: true}),
    w1, w2;


// Plot lattice points
for (let i = -5; i < 6; i++) {
    for (let j = -5; j < 6; j++) {
        if (!(i == 1 && j == 0) && !(i == 0 && j == 1)) { 
            board.create('point', [
                () => i * b1.X() + j * b2.X(),
                () => i * b1.Y() + j * b2.Y()
            ], {name:'', withLabel: false, size:2});
        }
    }
}

// Dual basis vectors
w1 = board.create('arrow', [[0,0], function() {
            var num = b1.X() * b2.Y() - b2.X() * b1.Y();
            return [b2.Y() / num,  -b2.X() / num];
}], {strokeColor: 'black', name:"b_1'", withLabel:true, label:{position:'rt'}});

w2 = board.create('arrow', [[0,0], function() {
            var num = b1.X() * b2.Y() - b2.X() * b1.Y();
            return [-b1.Y() / num,  b1.X() / num];
}], {strokeColor: 'red', name:"b_2'", withLabel:true, label:{position:'rt'}});

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.