Lattices: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 12: | Line 12: | ||
}} | }} | ||
</jsxgraph> | </jsxgraph> | ||
===Sphere packing=== | |||
<jsxgraph height="500" width="600" board="board" box="box2"> | |||
brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true}); | |||
var b3 = brd2.createElement('point', [1,0], {style:6,name:''}); | |||
var b4 = brd2.createElement('point', [0,1], {style:6,name:''}); | |||
var i, j; | |||
var p = []; | |||
for (i=-5;i<6;i++) for (j=-5;j<6;j++) { | |||
if (!(i==1&&j==0) && !(i==0&&j==1)) { | |||
p[i*11+j] = brd2.createElement('point',[ | |||
function(x,y){ return function(){ return x*b3.X()+y*b4.X(); };}(i,j), | |||
function(x,y){ return function(){ return x*b3.Y()+y*b4.Y(); };}(i,j) | |||
], {name:'',style:4}); | |||
brd2.createElement('circle',[p[i*11+j],0.5]); | |||
}} | |||
</jsxgraph> | |||
===JavaScript code for these examples=== | |||
Lattice: | |||
<source lang="xml"> | |||
<jsxgraph height="500" width="600" board="board" box="box1"> | |||
brd = JXG.JSXGraph.initBoard('box1', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true}); | |||
var b1 = brd.createElement('point', [1,0], {style:6,name:''}); | |||
var b2 = brd.createElement('point', [0,1], {style:6,name:''}); | |||
var i, j; | |||
for (i=-5;i<6;i++) for (j=-5;j<6;j++) { | |||
if (!(i==1&&j==0) && !(i==0&&j==1)) { | |||
brd.createElement('point',[ | |||
function(x,y){ return function(){ return x*b1.X()+y*b2.X(); };}(i,j), | |||
function(x,y){ return function(){ return x*b1.Y()+y*b2.Y(); };}(i,j) | |||
], {name:'',style:4}); | |||
}} | |||
</jsxgraph> | |||
</source> | |||
Spheres: | |||
<source lang="xml"> | |||
<jsxgraph height="500" width="600" board="board" box="box2"> | <jsxgraph height="500" width="600" board="board" box="box2"> | ||
brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true}); | brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true}); | ||
Line 29: | Line 63: | ||
}} | }} | ||
</jsxgraph> | </jsxgraph> | ||
</source> | |||
[[Category:Examples]] | [[Category:Examples]] |
Revision as of 07:33, 20 April 2009
Sphere packing
JavaScript code for these examples
Lattice:
<jsxgraph height="500" width="600" board="board" box="box1">
brd = JXG.JSXGraph.initBoard('box1', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true});
var b1 = brd.createElement('point', [1,0], {style:6,name:''});
var b2 = brd.createElement('point', [0,1], {style:6,name:''});
var i, j;
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
if (!(i==1&&j==0) && !(i==0&&j==1)) {
brd.createElement('point',[
function(x,y){ return function(){ return x*b1.X()+y*b2.X(); };}(i,j),
function(x,y){ return function(){ return x*b1.Y()+y*b2.Y(); };}(i,j)
], {name:'',style:4});
}}
</jsxgraph>
Spheres:
<jsxgraph height="500" width="600" board="board" box="box2">
brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true});
var b3 = brd2.createElement('point', [1,0], {style:6,name:''});
var b4 = brd2.createElement('point', [0,1], {style:6,name:''});
var i, j;
var p = [];
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
if (!(i==1&&j==0) && !(i==0&&j==1)) {
p[i*11+j] = brd2.createElement('point',[
function(x,y){ return function(){ return x*b3.X()+y*b4.X(); };}(i,j),
function(x,y){ return function(){ return x*b3.Y()+y*b4.Y(); };}(i,j)
], {name:'',style:4});
brd2.createElement('circle',[p[i*11+j],0.5]);
}}
</jsxgraph>