home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-08-13 | 30.4 KB | 1,962 lines |
- comment {
-
- Special coloring schemes developed by Kerry Mitchell
-
- Note! These are experimental, beta tests, highly specialized,
- or worse. Not for the faint of heart or new to UF. In general,
- there's little to no support or documentation. In short, you're
- on your own.
-
- Have fun! :-)
- }
-
-
- aug01-tangent-sine {
- real dx;
- parameter real nx;
- real Var_x;
- real Var_y;
- real h;
- real k;
- real m;
- real r;
- real rmin;
- int ix;
- parameter real a;
- parameter real b;
- parameter int linetype;
- parameter int updown;
-
- void init(void)
- {
- dx=pi*2/nx;
- Var_x=0.0;
- Var_y=0.0;
- h=0.0;
- k=0.0;
- m=0.0;
- r=0.0;
- rmin=1e20;
- ix=0;
- }
- void loop(void)
- {
- }
- void final(void)
- {
- ix=-1;
- Var_x=real(z);
- Var_y=imag(z);
- while ((ix<nx))
- {
- ix=ix+1;
- h=ix*dx-pi;
- k=a*sin(b*h);
- m=a*b*cos(b*h);
- if ((linetype==1))
- {// normal
- r=abs(Var_y-k+(Var_x-h)/m)*abs(m);
- }
- else
- {
- // tangent
- r=abs(Var_y-k-m*(Var_x-h));
- }
- if ((updown==1))
- {
- if (((r<rmin)&&(Var_y<k)))
- {
- rmin=r;
- }
- }
- else if ((updown==2))
- {
- if (((r<rmin)&&(Var_y>=k)))
- {
- rmin=r;
- }
- }
- else
- {
-
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- }
- index=rmin;
- }
- void description(void)
- {
- this.title="tangent sine";
-
- a.caption="amplitude";
- a.default=1.0;
-
-
- b.caption="frequency";
- b.default=1.0;
-
-
- nx.caption="# x points";
- nx.default=100;
-
-
- linetype.caption="line type";
- linetype.default=0;
- linetype.enum="tangent\nnormal";
-
-
- updown.caption="above/below";
- updown.default=0;
- updown.enum="both\nbelow only\nabove only";
-
- }
- }
-
-
- aug01-tangent-quadratic {
- real dx;
- parameter real xmax;
- parameter real xmin;
- parameter real nx;
- real Var_x;
- real Var_y;
- real h;
- real k;
- real m;
- real r;
- real rmin;
- int ix;
- parameter real a;
- parameter real b;
- parameter real c;
- parameter int linetype;
- parameter int updown;
-
- void init(void)
- {
- dx=(xmax-xmin)/nx;
- Var_x=0.0;
- Var_y=0.0;
- h=0.0;
- k=0.0;
- m=0.0;
- r=0.0;
- rmin=1e20;
- ix=0;
- }
- void loop(void)
- {
- }
- void final(void)
- {
- ix=-1;
- Var_x=real(z);
- Var_y=imag(z);
- while ((ix<nx))
- {
- ix=ix+1;
- h=ix*dx+xmin;
- k=(a*h+b)*h+c;
- m=2*a*h+b;
- if ((linetype==1))
- {// normal
- r=abs(Var_y-k+(Var_x-h)/m)*abs(m);
- }
- else
- {
- // tangent
- r=abs(Var_y-k-m*(Var_x-h));
- }
- if ((updown==1))
- {
- if (((r<rmin)&&(Var_y<k)))
- {
- rmin=r;
- }
- }
- else if ((updown==2))
- {
- if (((r<rmin)&&(Var_y>=k)))
- {
- rmin=r;
- }
- }
- else
- {
-
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- }
- index=rmin;
- }
- void description(void)
- {
- this.title="tangent quadratic";
-
- a.caption="a";
- a.default=1.0;
-
-
- b.caption="b";
- b.default=0.0;
-
-
- c.caption="c";
- c.default=0.0;
-
-
- xmin.caption="minimum x";
- xmin.default=-1.0;
-
-
- xmax.caption="maximum x";
- xmax.default=1.0;
-
-
- nx.caption="# x points";
- nx.default=100;
-
-
- linetype.caption="line type";
- linetype.default=0;
- linetype.enum="tangent\nnormal";
-
-
- updown.caption="above/below";
- updown.default=0;
- updown.enum="both\nbelow only\nabove only";
-
- }
- }
-
-
- aug01-tangent-rose {
- real dt;
- parameter real nt;
- real Var_x;
- real Var_y;
- real xp;
- real yp;
- real h;
- real k;
- real r;
- real rmin;
- real rz;
- real rc;
- real t;
- int it;
- parameter real a;
- parameter real b;
- parameter int linetype;
- parameter int updown;
-
- void init(void)
- {
- dt=pi*2/nt;
- Var_x=0.0;
- Var_y=0.0;
- xp=0.0;
- yp=0.0;
- h=0.0;
- k=0.0;
- r=0.0;
- rmin=1e20;
- rz=0.0;
- rc=0.0;
- t=0.0;
- it=0;
- }
- void loop(void)
- {
- }
- void final(void)
- {
- Var_x=real(z);
- Var_y=imag(z);
- rz=cabs(z);
- it=-1;
- while ((it<nt))
- {
- it=it+1;
- t=it*dt+dt/2;
- rc=a*cos(b*t);
- h=rc*cos(t);
- k=rc*sin(t);
- xp=-a*(cos(b*t)*sin(t)+3*sin(b*t)*cos(t));
- yp=a*(cos(b*t)*cos(t)-3*sin(b*t)*sin(t));
- if ((linetype==1))
- {// normal
- r=abs(yp*(Var_y-k)+xp*(Var_x-h));
- }
- else
- {
- // tangent
- r=abs(xp*(Var_y-k)-yp*(Var_x-h));
- }
- if ((updown==1))
- {
- if (((r<rmin)&&(rz<rc)))
- {
- rmin=r;
- }
- }
- else if ((updown==2))
- {
- if (((r<rmin)&&(rz>=rc)))
- {
- rmin=r;
- }
- }
- else
- {
-
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- }
- index=rmin;
- }
- void description(void)
- {
- this.title="tangent rose";
-
- a.caption="amplitude";
- a.default=1.0;
-
-
- b.caption="frequency";
- b.default=3.0;
-
-
- nt.caption="# points";
- nt.default=100;
-
-
- linetype.caption="line type";
- linetype.default=0;
- linetype.enum="tangent\nnormal";
-
-
- updown.caption="above/below";
- updown.default=0;
- updown.enum="both\nbelow only\nabove only";
-
- }
- }
-
-
- aug01-hilbert-spline2 {
- real Var_x;
- real Var_y;
- real r;
- real rmin;
- real u;
- real v;
- int iter;
- int nlast;
- int n;
- int fac3;
- int fac4;
- int power4;
- complex zh;
- real h;
- real ooh;
- real ooomh;
- real hoomh;
- complex z0a;
- parameter real enterexit;
- complex z0b;
- complex z1;
- parameter complex centerll;
- complex z2;
- parameter complex centerul;
- complex z3;
- parameter complex centerur;
- complex z4;
- parameter complex centerlr;
- complex z5;
- parameter real niter;
- complex z0;
- complex c01;
- parameter complex control01;
- complex zz0;
- complex zz2;
- complex c;
- complex zz1;
- complex b;
- complex a;
- complex root1;
- complex root2;
- complex d;
- parameter real scale01;
- parameter complex control12;
- parameter real scale12;
- parameter complex control23;
- parameter real scale23;
- parameter complex control34;
- parameter real scale34;
- parameter complex control45;
- parameter real scale45;
-
- void init(void)
- {
- Var_x=0.0;
- Var_y=0.0;
- r=0.0;
- rmin=1e20;
- u=0.0;
- v=0.0;
- iter=0;
- nlast=0;
- n=0;
- fac3=0;
- fac4=0;
- power4=0;
- zh=(0,0);
- //
- // set up endpoints for the lines
- //
- h=0.5;
- ooh=1/h;
- ooomh=1/(1-h);
- hoomh=h/(1-h);
- z0a=enterexit;
- z0b=flip(enterexit);
- z1=centerll;
- z2=centerul;
- z3=centerur;
- z4=centerlr;
- z5=1+flip(enterexit);
- }
- void loop(void)
- {
- }
- void final(void)
- {
- iter=0;
- zh=z*0.25+(0.5,0.5);
- while ((iter<niter))
- {
- iter=iter+1;
- Var_x=real(zh);
- Var_y=imag(zh);
- //
- // lower left sub-square: shrink, flip horizontally, rotate by -90 degrees
- //
- if (((Var_x<h)&&(Var_y<h)))
- {
- nlast=3;
- u=ooh*Var_y;
- v=ooh*Var_x;
- //
- // upper left sub-square: just shrink
- //
- }
- else if (((Var_x<h)&&(Var_y>=h)))
- {
- nlast=2;
- u=ooh*Var_x;
- v=ooomh*Var_y-hoomh;
- //
- // upper right sub-square: shrink & flip horizontally
- //
- }
- else if (((Var_x>=h)&&(Var_y>=h)))
- {
- nlast=1;
- u=ooomh-ooomh*Var_x;
- v=ooomh*Var_y-hoomh;
- //
- // lower right sub-square: shrink, rotate by 90 degrees
- //
- }
- else if (((Var_x>=h)&&(Var_y<h)))
- {
- nlast=4;
- u=ooh*Var_y;
- v=ooomh-ooomh*Var_x;
- }
- else
- {
-
- nlast=-1;
- u=Var_x;
- v=Var_y;
- }
- zh=u+flip(v);
- n=n*4+nlast-1;
- }
- //
- // determine how to start line 0-1
- //
- z0=z0a;
- c01=control01;
- iter=0;
- fac3=2;
- fac4=1;
- power4=4;
- while ((iter<niter))
- {
- iter=iter+1;
- if ((iter%2==1))
- {
- if ((n%power4==fac3))
- {
- z0=z0b;
- c01=flip(control01);
- }
- }
- else
- {
-
- if ((n%power4==fac3))
- {
- z0=z0a;
- c01=control01;
- }
- }
- power4=4*power4;
- fac4=4*fac4;
- fac3=fac3+2*fac4;
- }
- //
- // spline from enter to lower left sub-square
- //
- zz0=z0;
- zz2=z1;
- c=c01;
- if ((c==(99,99)))
- {
- zz1=(zz0+zz2)/2;
- }
- else
- {
-
- zz1=c;
- }
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- Var_y=imag(root1);
- if ((Var_x<0.0))
- {
- r=cabs(root1);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root1-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale01;
- if ((r<rmin))
- {
- rmin=r;
- }
- Var_x=real(root2);
- Var_y=imag(root2);
- if ((Var_x<0.0))
- {
- r=cabs(root2);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root2-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale01;
- if ((r<rmin))
- {
- rmin=r;
- }
- //
- // spline from lower left to upper left sub-square
- //
- zz0=z1;
- zz2=z2;
- c=control12;
- if ((c==(99,99)))
- {
- zz1=(zz0+zz2)/2;
- }
- else
- {
-
- zz1=c;
- }
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- Var_y=imag(root1);
- if ((Var_x<0.0))
- {
- r=cabs(root1);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root1-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale12;
- if ((r<rmin))
- {
- rmin=r;
- }
- Var_x=real(root2);
- Var_y=imag(root2);
- if ((Var_x<0.0))
- {
- r=cabs(root2);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root2-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale12;
- if ((r<rmin))
- {
- rmin=r;
- }
- //
- // spline from upper left to upper right sub-square
- //
- zz0=z2;
- zz2=z3;
- c=control23;
- if ((c==(99,99)))
- {
- zz1=(zz0+zz2)/2;
- }
- else
- {
-
- zz1=c;
- }
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- Var_y=imag(root1);
- if ((Var_x<0.0))
- {
- r=cabs(root1);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root1-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale23;
- if ((r<rmin))
- {
- rmin=r;
- }
- Var_x=real(root2);
- Var_y=imag(root2);
- if ((Var_x<0.0))
- {
- r=cabs(root2);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root2-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale23;
- if ((r<rmin))
- {
- rmin=r;
- }
- //
- // spline from upper right to lower right sub-square
- //
- zz0=z3;
- zz2=z4;
- c=control34;
- if ((c==(99,99)))
- {
- zz1=(zz0+zz2)/2;
- }
- else
- {
-
- zz1=c;
- }
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- Var_y=imag(root1);
- if ((Var_x<0.0))
- {
- r=cabs(root1);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root1-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale34;
- if ((r<rmin))
- {
- rmin=r;
- }
- Var_x=real(root2);
- Var_y=imag(root2);
- if ((Var_x<0.0))
- {
- r=cabs(root2);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root2-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale34;
- if ((r<rmin))
- {
- rmin=r;
- }
- //
- // spline from lower right sub-square to exit
- //
- zz0=z4;
- zz2=z5;
- c=control45;
- if ((c==(99,99)))
- {
- zz1=(zz0+zz2)/2;
- }
- else
- {
-
- zz1=c;
- }
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- Var_y=imag(root1);
- if ((Var_x<0.0))
- {
- r=cabs(root1);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root1-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale45;
- if ((r<rmin))
- {
- rmin=r;
- }
- Var_x=real(root2);
- Var_y=imag(root2);
- if ((Var_x<0.0))
- {
- r=cabs(root2);
- }
- else if ((Var_x>1.0))
- {
- r=cabs(root2-1);
- }
- else
- {
-
- r=abs(Var_y);
- }
- r=r/scale45;
- if ((r<rmin))
- {
- rmin=r;
- }
- //
- index=rmin;
- }
- void description(void)
- {
- this.title="Hilbert spline 2";
-
- niter.caption="iterations";
- niter.default=0;
- niter.min=0;
-
-
- centerll.caption="lower left center";
- centerll.default=(0.25,0.25);
- centerll.hint="Center of the lower left sub-square. Make both coordinates between 0 & 1; use (0.25,0.25) for standard Hilbert curve.";
-
-
- centerul.caption="upper left center";
- centerul.default=(0.25,0.75);
- centerul.hint="Center of the upper left sub-square. Make both coordinates between 0 & 1; use (0.25,0.75) for standard Hilbert curve.";
-
-
- centerur.caption="upper right center";
- centerur.default=(0.75,0.75);
- centerur.hint="Center of the upper right sub-square. Make both coordinates between 0 & 1; use (0.75,0.75) for standard Hilbert curve.";
-
-
- centerlr.caption="lower right center";
- centerlr.default=(0.75,0.25);
- centerlr.hint="Center of the lower right sub-square. Make both coordinates between 0 & 1; use (0.75,0.25) for standard Hilbert curve.";
-
-
- enterexit.caption="enter/exit";
- enterexit.default=0.25;
- enterexit.min=0.0;
- enterexit.max=1.0;
- enterexit.hint="Where the curve enters and exits the block of 4 sub-squares. Between 0 & 1; use 0.25 for standard Hilbert curve.";
-
-
- control01.caption="0-1 control pt";
- control01.default=(99,99);
- control01.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
-
-
- control12.caption="1-2 control pt";
- control12.default=(99,99);
- control12.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
-
-
- control23.caption="2-3 control pt";
- control23.default=(99,99);
- control23.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
-
-
- control34.caption="3-4 control pt";
- control34.default=(99,99);
- control34.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
-
-
- control45.caption="4-5 control pt";
- control45.default=(99,99);
- control45.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
-
-
- scale01.caption="0-1 scale";
- scale01.default=1.0;
- scale01.hint="Decrease to make line thinner.";
-
-
- scale12.caption="1-2 scale";
- scale12.default=1.0;
- scale12.hint="Decrease to make line thinner.";
-
-
- scale23.caption="2-3 scale";
- scale23.default=1.0;
- scale23.hint="Decrease to make line thinner.";
-
-
- scale34.caption="3-4 scale";
- scale34.default=1.0;
- scale34.hint="Decrease to make line thinner.";
-
-
- scale45.caption="4-5 scale";
- scale45.default=1.0;
- scale45.hint="Decrease to make line thinner.";
-
- }
- }
-
-
- aug01-metagon-semicircles2 {
- real r;
- real rmin;
- real theta;
- real dtheta;
- complex t;
- int iter;
- int iside;
- int kflip;
- complex z1;
- complex z2;
- parameter complex metagoncenter;
- parameter real rotdeg;
- parameter real length;
- parameter real nside;
- parameter real Parm_width;
-
- void init(void)
- {
- r=0.0;
- rmin=1e20;
- theta=0.0;
- dtheta=0.0;
- t=(0,0);
- iter=0;
- iside=0;
- kflip=-1;
- z1=(0,0);
- z2=(0,0);
- }
- void loop(void)
- {
- }
- void final(void)
- {
- iside=2;
- iter=0;
- z1=metagoncenter;
- theta=rotdeg*pi/180-pi;
- z2=z1+length*(cos(theta)+flip(sin(theta)));
- t=(z-z1)/(z2-z1);
- kflip=-kflip;
- if ((imag(t*kflip)>=0.0))
- {
- r=abs(cabs(t-0.5)-0.5)*cabs(z2-z1);
- }
- else
- {
-
- r=1e20;
- }
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(z-z1);
- if ((r<rmin))
- {
- rmin=r;
- }
- z1=z2;
- while ((iside<nside))
- {
- iside=iside+1;
- dtheta=pi-(iside-2)*pi/iside;
- iter=1;
- kflip=-1;
- while ((iter<iside))
- {
- iter=iter+1;
- theta=theta+dtheta;
- z2=z1+length*(cos(theta)+flip(sin(theta)));
- t=(z-z1)/(z2-z1);
- kflip=-kflip;
- if ((imag(t*kflip)>=0.0))
- {
- r=abs(cabs(t-0.5)-0.5)*cabs(z2-z1);
- }
- else
- {
-
- r=1e20;
- }
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(z-z1);
- if ((r<rmin))
- {
- rmin=r;
- }
- z1=z2;
- }
- }
- if ((rmin<=Parm_width))
- {
- index=rmin/Parm_width;
- }
- else
- {
-
- solid=true;
- }
- }
- void description(void)
- {
- this.title="metagon semicircles 2";
-
- nside.caption="final # of sides";
- nside.default=8;
- nside.min=3;
-
-
- length.caption="side length";
- length.default=1.0;
-
-
- metagoncenter.caption="center";
- metagoncenter.default=(0,0);
-
-
- rotdeg.caption="rotation, deg.";
- rotdeg.default=0.0;
-
-
- Parm_width.caption="thickness";
- Parm_width.default=0.1;
-
- }
- }
-
-
- aug01-hilbert-spline4 {
- real Var_x;
- real Var_y;
- real r;
- real rmin;
- real u;
- real v;
- int iter;
- int nlast;
- int n;
- int fac3;
- int fac4;
- int power4;
- complex zh;
- real h;
- real ooh;
- real ooomh;
- real hoomh;
- complex z0a;
- parameter real enterexit;
- complex z0b;
- complex z1;
- parameter complex centerll;
- complex z2;
- parameter complex centerul;
- complex z3;
- parameter complex centerur;
- complex z4;
- parameter complex centerlr;
- complex z5;
- complex control01;
- complex control12;
- complex control34;
- complex control45;
- parameter int type34;
- parameter complex control23;
- parameter real xc34;
- parameter int type45;
- parameter real yc45;
- parameter int type12;
- parameter real xc12;
- parameter int type01;
- parameter real xc01;
- parameter real niter;
- complex z0;
- complex c01;
- complex zz0;
- complex zz2;
- complex zz1;
- complex c;
- complex b;
- complex a;
- complex root1;
- complex root2;
- complex d;
- complex ztemp;
-
- void init(void)
- {
- Var_x=0.0;
- Var_y=0.0;
- r=0.0;
- rmin=1e20;
- u=0.0;
- v=0.0;
- iter=0;
- nlast=0;
- n=0;
- fac3=0;
- fac4=0;
- power4=0;
- zh=(0,0);
- //
- // set up endpoints for the lines
- //
- h=0.5;
- ooh=1/h;
- ooomh=1/(1-h);
- hoomh=h/(1-h);
- z0a=enterexit;
- z0b=flip(enterexit);
- z1=centerll;
- z2=centerul;
- z3=centerur;
- z4=centerlr;
- z5=1+flip(enterexit);
- control01=(0,0);
- control12=(0,0);
- control34=(0,0);
- control45=(0,0);
- //
- // control points
- //
- // line 3-4
- //
- if ((type34==1))
- {// normal to 2-3
- if ((imag(z3)==imag(control23)))
- {
- Var_y=real(z3)-real(control23)+imag(z3);
- }
- else
- {
-
- Var_y=(real(z3)-real(control23))/(imag(z3)-imag(control23))*(real(z3)-xc34)+imag(z3);
- }
- }
- else
- {
- // tangent to 2-3
- if ((real(z3)==real(control23)))
- {
- Var_y=2*imag(z3)-imag(control23);
- }
- else
- {
-
- Var_y=(imag(z3)-imag(control23))/(real(z3)-real(control23))*(xc34-real(z3))+imag(z3);
- }
- }
- control34=xc34+flip(Var_y);
- //
- // line 4-5
- //
- if ((type45==1))
- {// normal to 3-4
- if ((real(z4)==real(control34)))
- {
- Var_x=real(z4)-imag(z4)-imag(control34);
- }
- else
- {
-
- Var_x=-(imag(z4)-imag(control34))/(real(z4)-real(control34))*(yc45-imag(z4))+real(z4);
- }
- }
- else
- {
- // tangent to 3-4
- if ((imag(z4)==imag(control34)))
- {
- Var_x=2*real(z4)-real(control34);
- }
- else
- {
-
- Var_x=(real(z4)-real(control34))/(imag(z4)-imag(control34))*(yc45-imag(z4))+real(z4);
- }
- }
- control45=Var_x+flip(yc45);
- //
- // line 1-2
- //
- if ((type12==1))
- {// normal to 2-3
- if ((imag(z2)==imag(control23)))
- {
- Var_y=imag(z2)-real(control23)+real(z2);
- }
- else
- {
-
- Var_y=(real(control23)-real(z2))/(imag(control23)-imag(z2))*(real(z2)-xc12)+imag(z2);
- }
- }
- else
- {
- // tangent to 2-3
- if ((real(z2)==real(control23)))
- {
- Var_y=2*imag(z2)-imag(control23);
- }
- else
- {
-
- Var_y=-(imag(control23)-imag(z2))/(real(control23)-real(z2))*(real(z2)-xc12)+imag(z2);
- }
- }
- control12=xc12+flip(Var_y);
- //
- // line 0-1
- //
- if ((type01==1))
- {// normal to 1-2
- if ((imag(z1)==imag(control12)))
- {
- Var_y=imag(z1)-real(control12)+real(z1);
- }
- else
- {
-
- Var_y=(real(control12)-real(z1))/(imag(control12)-imag(z1))*(real(z1)-xc01)+imag(z1);
- }
- }
- else
- {
- // tangent to 1-2
- if ((real(z1)==real(control12)))
- {
- Var_y=2*imag(z1)-imag(control12);
- }
- else
- {
-
- Var_y=-(imag(control12)-imag(z1))/(real(control12)-real(z1))*(real(z1)-xc01)+imag(z1);
- }
- }
- control01=xc01+flip(Var_y);
- }
- void loop(void)
- {
- }
- void final(void)
- {
- iter=0;
- zh=z*0.25+(0.5,0.5);
- while ((iter<niter))
- {
- iter=iter+1;
- Var_x=real(zh);
- Var_y=imag(zh);
- //
- // lower left sub-square: shrink, flip horizontally, rotate by -90 degrees
- //
- if (((Var_x<h)&&(Var_y<h)))
- {
- nlast=3;
- u=ooh*Var_y;
- v=ooh*Var_x;
- //
- // upper left sub-square: just shrink
- //
- }
- else if (((Var_x<h)&&(Var_y>=h)))
- {
- nlast=2;
- u=ooh*Var_x;
- v=ooomh*Var_y-hoomh;
- //
- // upper right sub-square: shrink & flip horizontally
- //
- }
- else if (((Var_x>=h)&&(Var_y>=h)))
- {
- nlast=1;
- u=ooomh-ooomh*Var_x;
- v=ooomh*Var_y-hoomh;
- //
- // lower right sub-square: shrink, rotate by 90 degrees
- //
- }
- else if (((Var_x>=h)&&(Var_y<h)))
- {
- nlast=4;
- u=ooh*Var_y;
- v=ooomh-ooomh*Var_x;
- }
- else
- {
-
- nlast=-1;
- u=Var_x;
- v=Var_y;
- }
- zh=u+flip(v);
- n=n*4+nlast-1;
- }
- //
- // determine how to start line 0-1
- //
- z0=z0a;
- c01=control01;
- iter=0;
- fac3=2;
- fac4=1;
- power4=4;
- while ((iter<niter))
- {
- iter=iter+1;
- if ((iter%2==1))
- {
- if ((n%power4==fac3))
- {
- z0=z0b;
- c01=flip(control01);
- }
- }
- else
- {
-
- if ((n%power4==fac3))
- {
- z0=z0a;
- c01=control01;
- }
- }
- power4=4*power4;
- fac4=4*fac4;
- fac3=fac3+2*fac4;
- }
- //
- // spline from enter to lower left sub-square
- //
- zz0=z0;
- zz2=z1;
- zz1=c01;
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- Var_x=real(root2);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- //
- // spline from lower left to upper left sub-square
- //
- zz0=z1;
- zz2=z2;
- zz1=control12;
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- Var_x=real(root2);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- //
- // spline from upper left to upper right sub-square
- //
- zz0=z2;
- zz2=z3;
- zz1=control23;
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- Var_x=real(root2);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- //
- // spline from upper right to lower right sub-square
- //
- zz0=z3;
- zz2=z4;
- zz1=control34;
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- Var_x=real(root2);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- //
- // spline from lower right sub-square to exit
- //
- zz0=z4;
- zz2=z5;
- zz1=control45;
- c=zz0-zh;
- b=2*(zz1-zz0);
- a=zz2-2*zz1+zz0;
- if ((cabs(a)==0.0))
- {
- root1=-c/b;
- root2=-c/b;
- }
- else
- {
-
- d=sqrt(sqr(b)-4*a*c);
- root1=(-b+d)/2/a;
- root2=(-b-d)/2/a;
- }
- Var_x=real(root1);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- Var_x=real(root2);
- if (((Var_x>=0.0)&&(Var_x<=1.0)))
- {
- ztemp=(a*Var_x+b)*Var_x+c;
- r=cabs(ztemp);
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- //
- // balls at corners
- //
- r=cabs(zh-z0);
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(zh-z1);
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(zh-z2);
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(zh-z3);
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(zh-z4);
- if ((r<rmin))
- {
- rmin=r;
- }
- r=cabs(zh-z5);
- if ((r<rmin))
- {
- rmin=r;
- }
- //
- // set color
- //
- index=rmin;
- }
- void description(void)
- {
- this.title="Hilbert spline 4";
-
- niter.caption="iterations";
- niter.default=0;
- niter.min=0;
-
-
- centerll.caption="lower left center";
- centerll.default=(0.25,0.25);
- centerll.hint="Center of the lower left sub-square. Make both coordinates between 0 & 1; use (0.25,0.25) for standard Hilbert curve.";
-
-
- centerul.caption="upper left center";
- centerul.default=(0.25,0.75);
- centerul.hint="Center of the upper left sub-square. Make both coordinates between 0 & 1; use (0.25,0.75) for standard Hilbert curve.";
-
-
- centerur.caption="upper right center";
- centerur.default=(0.75,0.75);
- centerur.hint="Center of the upper right sub-square. Make both coordinates between 0 & 1; use (0.75,0.75) for standard Hilbert curve.";
-
-
- centerlr.caption="lower right center";
- centerlr.default=(0.75,0.25);
- centerlr.hint="Center of the lower right sub-square. Make both coordinates between 0 & 1; use (0.75,0.25) for standard Hilbert curve.";
-
-
- enterexit.caption="enter/exit";
- enterexit.default=0.25;
- enterexit.min=0.0;
- enterexit.max=1.0;
- enterexit.hint="Where the curve enters and exits the block of 4 sub-squares. Between 0 & 1; use 0.25 for standard Hilbert curve.";
-
-
- control23.caption="2-3 control pt";
- control23.default=(0.5,0.75);
- control23.hint="Both between 0 & 1.";
-
-
- type01.caption="0-1 line type";
- type01.default=0;
- type01.enum="tangent\nnormal";
- type01.hint="Relative to line 1-2.";
-
-
- type12.caption="1-2 line type";
- type12.default=0;
- type12.enum="tangent\nnormal";
- type12.hint="Relative to line 2-3.";
-
-
- type34.caption="3-4 line type";
- type34.default=0;
- type34.enum="tangent\nnormal";
- type34.hint="Relative to line 2-3.";
-
-
- type45.caption="4-5 line type";
- type45.default=0;
- type45.enum="tangent\nnormal";
- type45.hint="Relative to line 3-4.";
-
-
- xc01.caption="xc01";
- xc01.default=0.25;
-
-
- xc12.caption="xc12";
- xc12.default=0.25;
-
-
- xc34.caption="xc34";
- xc34.default=0.75;
-
-
- yc45.caption="yc45";
- yc45.default=0.25;
-
- }
- }
-
-
- aug01-tangent-tangent {
- real dx;
- parameter real nx;
- real Var_x;
- real Var_y;
- real h;
- real k;
- real m;
- real r;
- real rmin;
- int ix;
- parameter real a;
- parameter real b;
- parameter int linetype;
- parameter int updown;
-
- void init(void)
- {
- dx=pi*2/nx;
- Var_x=0.0;
- Var_y=0.0;
- h=0.0;
- k=0.0;
- m=0.0;
- r=0.0;
- rmin=1e20;
- ix=0;
- }
- void loop(void)
- {
- }
- void final(void)
- {
- ix=-1;
- Var_x=real(z);
- Var_y=imag(z);
- while ((ix<nx))
- {
- ix=ix+1;
- h=ix*dx-pi;
- k=a*tan(b*h);
- m=a*b/sqr(cos(b*h));
- if ((linetype==1))
- {// normal
- r=abs(Var_y-k+(Var_x-h)/m)*abs(m);
- }
- else
- {
- // tangent
- r=abs(Var_y-k-m*(Var_x-h));
- }
- if ((updown==1))
- {
- if (((r<rmin)&&(Var_y<k)))
- {
- rmin=r;
- }
- }
- else if ((updown==2))
- {
- if (((r<rmin)&&(Var_y>=k)))
- {
- rmin=r;
- }
- }
- else
- {
-
- if ((r<rmin))
- {
- rmin=r;
- }
- }
- }
- index=rmin;
- }
- void description(void)
- {
- this.title="tangent tangent";
-
- a.caption="amplitude";
- a.default=1.0;
-
-
- b.caption="frequency";
- b.default=1.0;
-
-
- nx.caption="# x points";
- nx.default=100;
-
-
- linetype.caption="line type";
- linetype.default=0;
- linetype.enum="tangent\nnormal";
-
-
- updown.caption="above/below";
- updown.default=0;
- updown.enum="both\nbelow only\nabove only";
-
- }
- }
-
-
- aug01-square-trap {
- real Var_x;
- real Var_y;
- real t;
- real halfside;
- parameter real side;
- int iter;
- int iterin;
- complex z1;
- complex zn;
- complex temp;
- parameter complex squarecenter;
- parameter int colorby;
-
- void init(void)
- {
- Var_x=0.0;
- Var_y=0.0;
- t=0.0;
- halfside=side/2;
- iter=0;
- iterin=0;
- z1=(0,0);
- zn=(0,0);
- }
- void loop(void)
- {
- iter=iter+1;
- temp=z-squarecenter;
- Var_x=real(temp);
- Var_y=imag(temp);
- if (((abs(Var_x)<=halfside)&&(abs(Var_y)<=halfside)))
- {
- iterin=iterin+1;
- zn=z;
- if ((iterin==1))
- {
- iterin=iter;
- z1=zn;
- }
- }
- }
- void final(void)
- {
- if ((iterin==0))
- {
- solid=true;
- }
- else
- {
-
- if ((colorby==1))
- {// 1st magnitude
- index=cabs(z1);
- }
- else if ((colorby==2))
- {// 1st angle
- t=atan2(z1)/pi;
- if ((t<0.0))
- {
- t=t+2.0;
- }
- index=0.5*t;
- }
- else if ((colorby==3))
- {// 1st real
- temp=z1-squarecenter;
- index=(real(temp)+halfside)/side;
- }
- else if ((colorby==4))
- {// 1st imag
- temp=z1-squarecenter;
- index=(imag(temp)+halfside)/side;
- }
- else if ((colorby==5))
- {// last magnitude
- index=cabs(zn);
- }
- else if ((colorby==6))
- {// last angle
- t=atan2(zn)/pi;
- if ((t<0.0))
- {
- t=t+2.0;
- }
- index=0.5*t;
- }
- else if ((colorby==7))
- {// last real
- temp=zn-squarecenter;
- index=(real(temp)+halfside)/side;
- }
- else if ((colorby==8))
- {// last imag
- temp=zn-squarecenter;
- index=(imag(temp)+halfside)/side;
- }
- else
- {
- // howmany
- index=iterin/10;
- }
- }
- }
- void description(void)
- {
- this.title="square trap";
-
- squarecenter.caption="center";
- squarecenter.default=(0.0,0.0);
-
-
- side.caption="side";
- side.default=1.0;
- side.min=0.0;
-
-
- colorby.caption="color by";
- colorby.default=0;
- colorby.enum="how many\n1st mag\n1st angle\n1st real\n1st imag\nlast mag\nlast angle\nlast real\nlast imag";
-
- }
- }
-
-
-