//Snake S = new Snake(50); Snake S = new Snake(500); class Snake { int nmax=1000; int n=0; pt S[] = new pt[nmax]; float L[] = new float [nmax], R[] = new float [nmax], W[] = new float [nmax], B[] = new float [nmax]; Snake() {}; Snake(int pn) {n=pn; println("snake of "+n);}; void declare() {for(int i=0; i3*n/4) return (1-sq(cos(PI*(i-n/2)/n*2)))*v; else return v; } pt offset(pt A, pt B, pt C, float a, float b, float c, float s) { float x,y, dr; // displacements and radius derivative vec V=A.vecTo(C); float nn= V.norm(); V.unit(); vec N=V.left(); dr=(c-a)/nn; x=-dr*b; y=sqrt(sq(b)-sq(x)); pt H=B.makeCopy(); H.addScaledVec(x,V); H.addScaledVec(s*y,N); return H; }