Lattices: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
<jsxgraph height="500" width="600" board="board"  box="box1">
<jsxgraph height="500" width="500" board="board"  box="box1">
brd = JXG.JSXGraph.initBoard('box1', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true});
brd = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
var b1 = brd.createElement('point', [1,0], {style:6,name:''});
brd.suspendUpdate();
var b2 = brd.createElement('point', [0,1], {style:6,name:''});
var b1 = brd.create('point', [1,0], {size:6, name:'', color:'blue'});
var b2 = brd.create('point', [0,1], {size:6, name:'', color:'blue'});
var i, j;
var i, j;
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   brd.createElement('point',[
   brd.create('point',[
       function(x,y){ return function(){ return x*b1.X()+y*b2.X(); };}(i,j),
       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)
       function(x,y){ return function(){ return x*b1.Y()+y*b2.Y(); };}(i,j)
       ], {name:'',style:4});
       ], {name:'',style:4});
}}
}}
brd.unsuspendUpdate();
</jsxgraph>
</jsxgraph>
===Sphere packing===
===Sphere packing===
<jsxgraph height="500" width="600" board="board"  box="box2">
<jsxgraph height="500" width="500" board="board"  box="box2">
brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true});
brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-5, 5, 5, -5], axis:true});
var b3 = brd2.createElement('point', [1,0], {style:6,name:''});
brd2.suspendUpdate();
var b4 = brd2.createElement('point', [0,1], {style:6,name:''});
var b3 = brd2.create('point', [1,0], {size:6, name:'', color:'blue'});
var i, j;
var b4 = brd2.create('point', [0,1], {size:6, name:'', color:'blue'});
var p = [];
var p = [];
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   p[i*11+j] = brd2.createElement('point',[
   p[i*11+j] = brd2.create('point',[
       function(x,y){ return function(){ return x*b3.X()+y*b4.X(); };}(i,j),
       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)
       function(x,y){ return function(){ return x*b3.Y()+y*b4.Y(); };}(i,j)
Line 27: Line 29:
   brd2.createElement('circle',[p[i*11+j],0.5]);
   brd2.createElement('circle',[p[i*11+j],0.5]);
}}
}}
brd2.unsuspendUpdate();
</jsxgraph>
</jsxgraph>
===JavaScript code for these examples===
===JavaScript code for these examples===
Lattice:
Lattice:
<source lang="xml">
<source lang="javascript">
<jsxgraph height="500" width="600" board="board"  box="box1">
var brd = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
brd = JXG.JSXGraph.initBoard('box1', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true});
brd.suspendUpdate();
var b1 = brd.createElement('point', [1,0], {style:6,name:''});
var b1 = brd.create('point', [1,0], {size:6, name:'', color:'blue'});
var b2 = brd.createElement('point', [0,1], {style:6,name:''});
var b2 = brd.create('point', [0,1], {size:6, name:'', color:'blue'});
var i, j;
var i, j;
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   brd.createElement('point',[
   brd.create('point',[
       function(x,y){ return function(){ return x*b1.X()+y*b2.X(); };}(i,j),
       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)
       function(x,y){ return function(){ return x*b1.Y()+y*b2.Y(); };}(i,j)
       ], {name:'',style:4});
       ], {name:'',style:4});
}}
}}
</jsxgraph>
brd.unsuspendUpdate();
</source>
</source>


Spheres:
Spheres:
<source lang="xml">
<source lang="javascript">
<jsxgraph height="500" width="600" board="board"  box="box2">
var brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-5, 5, 5, -5], axis:true});
brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 50, unitY: 50, axis:true});
brd2.suspendUpdate();
var b3 = brd2.createElement('point', [1,0], {style:6,name:''});
var b3 = brd2.create('point', [1,0], {size:6, name:'', color:'blue'});
var b4 = brd2.createElement('point', [0,1], {style:6,name:''});
var b4 = brd2.create('point', [0,1], {size:6, name:'', color:'blue'});
var i, j;
var p = [];
var p = [];
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
for (i=-5;i<6;i++) for (j=-5;j<6;j++) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   if (!(i==1&&j==0) && !(i==0&&j==1)) {
   p[i*11+j] = brd2.createElement('point',[
   p[i*11+j] = brd2.create('point',[
       function(x,y){ return function(){ return x*b3.X()+y*b4.X(); };}(i,j),
       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)
       function(x,y){ return function(){ return x*b3.Y()+y*b4.Y(); };}(i,j)
Line 62: Line 64:
   brd2.createElement('circle',[p[i*11+j],0.5]);
   brd2.createElement('circle',[p[i*11+j],0.5]);
}}
}}
</jsxgraph>
brd2.unsuspendUpdate();
</source>
</source>


[[Category:Examples]]
[[Category:Examples]]

Latest revision as of 08:09, 8 June 2011

Sphere packing

JavaScript code for these examples

Lattice:

var brd = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
brd.suspendUpdate();
var b1 = brd.create('point', [1,0], {size:6, name:'', color:'blue'});
var b2 = brd.create('point', [0,1], {size:6, name:'', color:'blue'});
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.create('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});
}}
brd.unsuspendUpdate();

Spheres:

var brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-5, 5, 5, -5], axis:true});
brd2.suspendUpdate();
var b3 = brd2.create('point', [1,0], {size:6, name:'', color:'blue'});
var b4 = brd2.create('point', [0,1], {size:6, name:'', color:'blue'});
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.create('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]);
}}
brd2.unsuspendUpdate();