float fi=0; float x,y,z,r; int i,j,k; float angle=0; int NSEGMENTS=3000; int N=40; int M=18; void setup() { size(600, 600,P3D); colorMode(RGB,200); } void DrawKnot1() { int i; float x,y,z,xl,yl,zl; float x2,y2,z2; float mu; float r; float beta; float mx=mouseX; float my=mouseY; float phi,theta; zl=yl=xl=-255; beginShape(LINES); for (i=0;i<=NSEGMENTS;i++) { mu = i * TWO_PI / (float)NSEGMENTS; x = 10 * (cos(mu) + cos(3*mu)) + cos(2*mu) + cos(4*mu); y = 6 * sin(mu) + 10 * sin(3*mu); z = 4 * sin(3*mu) * sin(5*mu/2) + 4*sin(4*mu) - 2 * sin(6*mu); beta = 100*i * PI / (float)NSEGMENTS; r = mx/100*1.2 * 0.6 * sin(0.5 * PI + 6 * beta); theta = 4 * beta/my; phi = 0.2 * PI * sin(6 * beta); x2 = r * cos(phi) * cos(theta)*50; y2 = r * cos(phi) * sin(theta)*50; z2 = r * sin(phi)*50; stroke(100,theta*100,beta/2,(z*z2)/3); if (zl==-255) { xl=x; yl=y; zl=z; } /* vertex(x,y,z); vertex(x2,y2,z2);*/ // vertex(0,0,0); bezier(x2,y2,z2,0,0,0,x,y,z,0,0,0); xl=x; yl=y; zl=z; } endShape(); } void draw() { background(0,0,0); translate(300,300); scale(8,8,8); /* rotateX(radians(mouseX)); rotateY(radians(mouseY));*/ rotateZ(angle); angle+=PI/180.0f; DrawKnot1(); }