/************************************************************************************************ * * SpacialData * * divides the total space into quadrants with the side length of the bird's perception radius * * requirements: * an Object gives a spacial position, SpacialData returns all Birds within its and its neigboughring quadrants * how to do this? * * *************************************************************************************************/ class SpacialData { int nrX=0, nrY=0, nrZ=0; int nrOfSpaceBoxes=0; double loX=0, loY=0, loZ=0; double side=0; // each spaceBox holds the reference to a number of birds Vector[][][] spaceBox; // this vector holds all the birds in the possible range Vector birdsInPossibleRange=new Vector(); SpacialData() { } void init(double rx, double ry, double rz, double r) { loX=-rx/2.0; loY=-ry/2.0; loZ=-rz/2.0; if (Math.floor(rx/r)==rx/r) { nrX=(int)(rx/r); } else { nrX=(int)(rx/r)+1; } if (Math.floor(ry/r)==ry/r) { nrY=(int)(ry/r); } else { nrY=(int)(ry/r)+1; } if (Math.floor(rz/r)==rz/r) { nrZ=(int)(rz/r); } else { nrZ=(int)(rz/r)+1; } nrOfSpaceBoxes=nrX*nrY*nrZ; side=r; println("Spacial Data grid is: "+nrX+","+nrY+","+nrZ); clear(); } void clear() { spaceBox=new Vector[nrX][nrY][nrZ]; for (int x=0;x=0&&x=0&&y=0&&zbird.getPerceptionRadius()) { birdsInPossibleRange.remove(targetBird); } else { bird.neighbourBirds.addElement(targetBird); } } } void drawLocalBox(double _x, double _y, double _z) { Vec tempIndex=new Vec(_x,_y,_z); if (_x>=0&&_x=0&&_y=0&&_z