Would be nice to see the source code for those images. I get something totally different when I use the vectors in the original post. I had to scale it up x100 for each point and move it over into the center of the window to get the image shown below. It’s flipped compared to what you would plot on graph paper because the computer screen’s origin is left, top.
int num = 6;
PVector[] v = new PVector[num];
void setup() {
size(400,400);
v[0] = new PVector(0,1);
v[1] = new PVector(0,2);
v[2] = new PVector(0,3);
v[3] = new PVector(1,2);
v[4] = new PVector(1,3);
v[5] = new PVector(2,3);
for(int i = 0; i < num; i++){
for(int j = i+1; j < num; j++){
println(i,j);
line(100 + v[i].x*100, v[i].y*100, 100 + v[j].x*100, v[j].y*100);
}
}
}
Effectively the algorithm finds every unique pair of values in a set. I have used this algorithm a lot when performing collision detection.
Since there is no processing to be done when i == num - 1 I have adjusted the outer loop to remove redundant processing.
size(300, 300);
translate(width/2, height/2);
strokeWeight(3);
int num = 5;
PVector [] v = new PVector[num];
float r = 100;
for (int p = 0; p < num; p++) {
float angle = p * TAU/num;
v[p] = new PVector(r * cos(angle), r * sin(angle));
}
// Outer loop limit changed
for (int i = 0; i < num - 1; i++) {
for (int j = i + 1; j < num; j++) {
line(v[i].x, v[i].y, v[j].x, v[j].y);
}
}