I am just playing around with the Mesh Library by Lee Byron and try to get the example to work. http://leebyron.com/else/mesh/
The first example he provides works fine
Code:
import megamu.mesh.*;
float[][] points = new float[5][2];
Delaunay myDelaunay ;
void setup(){
size(600,600);
background(255);
points[0][0] = 120; // first point, x
points[0][1] = 230; // first point, y
points[1][0] = 150; // second point, x
points[1][1] = 105; // second point, y
points[2][0] = 320; // third point, x
points[2][1] = 113; // third point, y
points[3][0] = 220; //
points[3][1] = 413; //
points[4][0] = 160; //
points[4][1] = 253; //
myDelaunay = new Delaunay( points );
}
void draw(){
background(255);
stroke(9);
float[][] myEdges = myDelaunay.getEdges();
for(int i=0; i<myEdges.length; i++)
{
float startX = myEdges[i][0];
float startY = myEdges[i][1];
float endX = myEdges[i][2];
float endY = myEdges[i][3];
line( startX, startY, endX, endY );
}
}
but using the
getLinks() example i get an indexOutofBounds
any ideas why ?
Code:
import megamu.mesh.*;
float[][] points = new float[5][2];
Delaunay myDelaunay ;
void setup(){
size(600,600);
background(255);
points[0][0] = 120; // first point, x
points[0][1] = 230; // first point, y
points[1][0] = 150; // second point, x
points[1][1] = 105; // second point, y
points[2][0] = 320; // third point, x
points[2][1] = 113; // third point, y
points[3][0] = 220; //
points[3][1] = 413; //
points[4][0] = 160; //
points[4][1] = 253; //
myDelaunay = new Delaunay( points );
}
void draw(){
background(255);
stroke(9);
int[][] myLinks = myDelaunay.getLinks();
for(int i=0; i<myLinks.length; i++)
{
int startIndex = myLinks[i][0];
int endIndex = myLinks[i][1];
float startX = points[startIndex][0];
float startY = points[startIndex][1];
float endX = points[endIndex][2];
float endY = points[endIndex][3];
line( startX, startY, endX, endY );
}
}