## class Tiling – the code

```//  a class for the points of a tiling

class Tiling{
TPoint[] points;

Tiling(){
points=new TPoint[0];
}

// adding a new point to the tiling

points=(TPoint[]) append(points,p);
}

//  show all points of the tiling
void showPoints(){
for (int i=0;i < points.length;i++){
points[i].showPoint();
}
}

//  show all lines (connections) of the tiling
void showConnections(){
for (int i=0;i < points.length;i++){
points[i].showConnections();
}
}

//  show all tilesof the tiling
void showTiles(){
for (int i=0;i < points.length;i++){
points[i].showTiles();
}
}

//  sort lines (connections) of each point of the tiling
void sortConnections(){
for (int i=0;i < points.length;i++){
points[i].sortConnections();
}
}

//----------------------------------------------------------------

//  calculates the square of the distance between two points
//  would better be part of class Vector

float distanceSquare(int i,int j){
return sq(points[i].vec.x-points[j].vec.x)+sq(points[i].vec.y-points[j].vec.y);
}

//find minmum distance between points (squared)
float minDistanceSquare(){
int i,j;
float mini=1e10;
for(i=0;i < points.length-1;i++){
for(j=i+1;j < points.length;j++){
mini=min(mini,distanceSquare(i,j));
}
}
return mini;
}

//generate lines of given length (squared)
//  saved as connections between tiling points
void generateLines(float lineLengthSquare){
int i,j;
for(i=0;i < points.length-1;i++){
for(j=i+1;j < points.length;j++){
if(abs(distanceSquare(i,j)-lineLengthSquare) < small){
//   points[i].vec.showLine(points[j].vec);