my solution would be switching to p3d and using the depth sort to try and draw the braids the correct order:
//Number of Strands
int nos;
//Phase difference b/w strands
float phase;
float[][] x;
float amp;
float time;
void setup() {
size(1000, 900,P3D);
background(0);
ortho();//no persepctive distortion
amp=70;
nos=5;
phase=TWO_PI/nos;
x=new float[nos][height+1];
}
void draw() {
background(0);
clear();
translate(width/2, 0);
for (int j=0; j<nos; j++) {
time=0;
for (int i=0; i<=height; i++) {
x[j][i]=amp* cos(time-(j*phase));
time+=0.027;
}
}
float thickness = 20;
for (int j=0; j<nos; j++) {
strokeWeight(thickness);
stroke(255, (255/nos)*(j+1), 255*(j-1));
noFill();
beginShape();
for (int i=1; i<=height; i++) {
int drawoffset =
9999- //% doesnt work as a stepper function expected with negative values like glsl does so a large offset is needed
int(
((thickness/0.027-6+i)*0.027)//current position on the cos function, need to offset to account for line thickness
/(2*PI/nos) //peroid of cos with amount of braids
);
int actualj = ((j+drawoffset)%nos);
// use vertex correctly, as opposed to line() which doesnt need a begin shape
vertex(x[j][i], i,80*actualj); //80 is an arbitary value, but keep it resonablely big to avoid z clipping
}
endShape();
}
}
Hi thanks @Xelo. This is useful although technically a braid has loops going in and out. Wire overlaps & then gets overlapped successively.
I though haven’t worked on 3d yet so will work around this:)