float fi=0; float x,y,z,r; int i,j,k; float angle=0; int NSEGMENTS=4000; int N=40; int M=18; int SPHEREN = 16; float r2 = 0.15; void setup() { size(400, 400,P3D); colorMode(RGB,200); } void DrawKnot1() { int i; float x,y,z,xl,yl,zl; float x2,y2,z2; float mu; float r=0; float beta; float mx=mouseX; float my=mouseY; float phi,theta; float nlongitude=mx/40; float nmeridian=my/40; zl=yl=xl=-255; beginShape(LINES); for (i=0;i<=NSEGMENTS;i++) { mu = i * TWO_PI * nmeridian / (float)NSEGMENTS; x = cos(mu) * (1 + cos(nlongitude*mu/(float)nmeridian) / 2.0); y = sin(mu) * (1 + cos(nlongitude*mu/(float)nmeridian) / 2.0); z = sin(nlongitude*mu/(float)nmeridian) / 2.0; if (zl==-255) { xl=x; yl=y; zl=z; } stroke(200,100,0,mu*5); vertex(x,y,z); vertex(xl,yl,zl); xl=x; yl=y; zl=z; } endShape(); } void draw() { background(0,0,0); translate(200,200); scale(100,100,100); rotateX(radians(mouseX)); rotateY(radians(mouseY)); rotateZ(angle); angle+=PI/180.0f; DrawKnot1(); }