home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 November / Chip_2001-11_cd1.bin / sharewar / chaospro / cpro302.exe / LKM-SPECIAL.CCL < prev    next >
Encoding:
Text File  |  2001-08-13  |  30.4 KB  |  1,962 lines

  1. comment {
  2.  
  3. Special coloring schemes developed by Kerry Mitchell 
  4.  
  5. Note! These are experimental, beta tests, highly specialized, 
  6. or worse. Not for the faint of heart or new to UF. In general, 
  7. there's little to no support or documentation. In short, you're 
  8. on your own.
  9.  
  10. Have fun! :-)
  11. }
  12.  
  13.  
  14. aug01-tangent-sine {
  15. real dx;
  16. parameter real nx;
  17. real Var_x;
  18. real Var_y;
  19. real h;
  20. real k;
  21. real m;
  22. real r;
  23. real rmin;
  24. int ix;
  25. parameter real a;
  26. parameter real b;
  27. parameter int linetype;
  28. parameter int updown;
  29.  
  30.     void init(void)
  31.     {
  32.         dx=pi*2/nx;
  33.         Var_x=0.0;
  34.         Var_y=0.0;
  35.         h=0.0;
  36.         k=0.0;
  37.         m=0.0;
  38.         r=0.0;
  39.         rmin=1e20;
  40.         ix=0;
  41.     }
  42.     void loop(void)
  43.     {
  44.     }
  45.     void final(void)
  46.     {
  47.         ix=-1;
  48.         Var_x=real(z);
  49.         Var_y=imag(z);
  50.         while ((ix<nx))
  51.         {
  52.             ix=ix+1;
  53.             h=ix*dx-pi;
  54.             k=a*sin(b*h);
  55.             m=a*b*cos(b*h);
  56.             if ((linetype==1))
  57.             {// normal
  58.                 r=abs(Var_y-k+(Var_x-h)/m)*abs(m);
  59.             }
  60.             else
  61.             {
  62.                      // tangent
  63.                 r=abs(Var_y-k-m*(Var_x-h));
  64.             }
  65.             if ((updown==1))
  66.             {
  67.                 if (((r<rmin)&&(Var_y<k)))
  68.                 {
  69.                     rmin=r;
  70.                 }
  71.             }
  72.             else if ((updown==2))
  73.             {
  74.                 if (((r<rmin)&&(Var_y>=k)))
  75.                 {
  76.                     rmin=r;
  77.                 }
  78.             }
  79.             else
  80.             {
  81.  
  82.                 if ((r<rmin))
  83.                 {
  84.                     rmin=r;
  85.                 }
  86.             }
  87.         }
  88.         index=rmin;
  89.     }
  90.     void description(void)
  91.     {
  92.         this.title="tangent sine";
  93.    
  94.         a.caption="amplitude";
  95.         a.default=1.0;
  96.   
  97.    
  98.         b.caption="frequency";
  99.         b.default=1.0;
  100.   
  101.    
  102.         nx.caption="# x points";
  103.         nx.default=100;
  104.   
  105.    
  106.         linetype.caption="line type";
  107.         linetype.default=0;
  108.         linetype.enum="tangent\nnormal";
  109.   
  110.    
  111.         updown.caption="above/below";
  112.         updown.default=0;
  113.         updown.enum="both\nbelow only\nabove only";
  114.   
  115.     }
  116. }
  117.  
  118.  
  119. aug01-tangent-quadratic {
  120. real dx;
  121. parameter real xmax;
  122. parameter real xmin;
  123. parameter real nx;
  124. real Var_x;
  125. real Var_y;
  126. real h;
  127. real k;
  128. real m;
  129. real r;
  130. real rmin;
  131. int ix;
  132. parameter real a;
  133. parameter real b;
  134. parameter real c;
  135. parameter int linetype;
  136. parameter int updown;
  137.  
  138.     void init(void)
  139.     {
  140.         dx=(xmax-xmin)/nx;
  141.         Var_x=0.0;
  142.         Var_y=0.0;
  143.         h=0.0;
  144.         k=0.0;
  145.         m=0.0;
  146.         r=0.0;
  147.         rmin=1e20;
  148.         ix=0;
  149.     }
  150.     void loop(void)
  151.     {
  152.     }
  153.     void final(void)
  154.     {
  155.         ix=-1;
  156.         Var_x=real(z);
  157.         Var_y=imag(z);
  158.         while ((ix<nx))
  159.         {
  160.             ix=ix+1;
  161.             h=ix*dx+xmin;
  162.             k=(a*h+b)*h+c;
  163.             m=2*a*h+b;
  164.             if ((linetype==1))
  165.             {// normal
  166.                 r=abs(Var_y-k+(Var_x-h)/m)*abs(m);
  167.             }
  168.             else
  169.             {
  170.                      // tangent
  171.                 r=abs(Var_y-k-m*(Var_x-h));
  172.             }
  173.             if ((updown==1))
  174.             {
  175.                 if (((r<rmin)&&(Var_y<k)))
  176.                 {
  177.                     rmin=r;
  178.                 }
  179.             }
  180.             else if ((updown==2))
  181.             {
  182.                 if (((r<rmin)&&(Var_y>=k)))
  183.                 {
  184.                     rmin=r;
  185.                 }
  186.             }
  187.             else
  188.             {
  189.  
  190.                 if ((r<rmin))
  191.                 {
  192.                     rmin=r;
  193.                 }
  194.             }
  195.         }
  196.         index=rmin;
  197.     }
  198.     void description(void)
  199.     {
  200.         this.title="tangent quadratic";
  201.    
  202.         a.caption="a";
  203.         a.default=1.0;
  204.   
  205.    
  206.         b.caption="b";
  207.         b.default=0.0;
  208.   
  209.    
  210.         c.caption="c";
  211.         c.default=0.0;
  212.   
  213.    
  214.         xmin.caption="minimum x";
  215.         xmin.default=-1.0;
  216.   
  217.    
  218.         xmax.caption="maximum x";
  219.         xmax.default=1.0;
  220.   
  221.    
  222.         nx.caption="# x points";
  223.         nx.default=100;
  224.   
  225.    
  226.         linetype.caption="line type";
  227.         linetype.default=0;
  228.         linetype.enum="tangent\nnormal";
  229.   
  230.    
  231.         updown.caption="above/below";
  232.         updown.default=0;
  233.         updown.enum="both\nbelow only\nabove only";
  234.   
  235.     }
  236. }
  237.  
  238.  
  239. aug01-tangent-rose {
  240. real dt;
  241. parameter real nt;
  242. real Var_x;
  243. real Var_y;
  244. real xp;
  245. real yp;
  246. real h;
  247. real k;
  248. real r;
  249. real rmin;
  250. real rz;
  251. real rc;
  252. real t;
  253. int it;
  254. parameter real a;
  255. parameter real b;
  256. parameter int linetype;
  257. parameter int updown;
  258.  
  259.     void init(void)
  260.     {
  261.         dt=pi*2/nt;
  262.         Var_x=0.0;
  263.         Var_y=0.0;
  264.         xp=0.0;
  265.         yp=0.0;
  266.         h=0.0;
  267.         k=0.0;
  268.         r=0.0;
  269.         rmin=1e20;
  270.         rz=0.0;
  271.         rc=0.0;
  272.         t=0.0;
  273.         it=0;
  274.     }
  275.     void loop(void)
  276.     {
  277.     }
  278.     void final(void)
  279.     {
  280.         Var_x=real(z);
  281.         Var_y=imag(z);
  282.         rz=cabs(z);
  283.         it=-1;
  284.         while ((it<nt))
  285.         {
  286.             it=it+1;
  287.             t=it*dt+dt/2;
  288.             rc=a*cos(b*t);
  289.             h=rc*cos(t);
  290.             k=rc*sin(t);
  291.             xp=-a*(cos(b*t)*sin(t)+3*sin(b*t)*cos(t));
  292.             yp=a*(cos(b*t)*cos(t)-3*sin(b*t)*sin(t));
  293.             if ((linetype==1))
  294.             {// normal
  295.                 r=abs(yp*(Var_y-k)+xp*(Var_x-h));
  296.             }
  297.             else
  298.             {
  299.                      // tangent
  300.                 r=abs(xp*(Var_y-k)-yp*(Var_x-h));
  301.             }
  302.             if ((updown==1))
  303.             {
  304.                 if (((r<rmin)&&(rz<rc)))
  305.                 {
  306.                     rmin=r;
  307.                 }
  308.             }
  309.             else if ((updown==2))
  310.             {
  311.                 if (((r<rmin)&&(rz>=rc)))
  312.                 {
  313.                     rmin=r;
  314.                 }
  315.             }
  316.             else
  317.             {
  318.  
  319.                 if ((r<rmin))
  320.                 {
  321.                     rmin=r;
  322.                 }
  323.             }
  324.         }
  325.         index=rmin;
  326.     }
  327.     void description(void)
  328.     {
  329.         this.title="tangent rose";
  330.    
  331.         a.caption="amplitude";
  332.         a.default=1.0;
  333.   
  334.    
  335.         b.caption="frequency";
  336.         b.default=3.0;
  337.   
  338.    
  339.         nt.caption="# points";
  340.         nt.default=100;
  341.   
  342.    
  343.         linetype.caption="line type";
  344.         linetype.default=0;
  345.         linetype.enum="tangent\nnormal";
  346.   
  347.    
  348.         updown.caption="above/below";
  349.         updown.default=0;
  350.         updown.enum="both\nbelow only\nabove only";
  351.   
  352.     }
  353. }
  354.  
  355.  
  356. aug01-hilbert-spline2 {
  357. real Var_x;
  358. real Var_y;
  359. real r;
  360. real rmin;
  361. real u;
  362. real v;
  363. int iter;
  364. int nlast;
  365. int n;
  366. int fac3;
  367. int fac4;
  368. int power4;
  369. complex zh;
  370. real h;
  371. real ooh;
  372. real ooomh;
  373. real hoomh;
  374. complex z0a;
  375. parameter real enterexit;
  376. complex z0b;
  377. complex z1;
  378. parameter complex centerll;
  379. complex z2;
  380. parameter complex centerul;
  381. complex z3;
  382. parameter complex centerur;
  383. complex z4;
  384. parameter complex centerlr;
  385. complex z5;
  386. parameter real niter;
  387. complex z0;
  388. complex c01;
  389. parameter complex control01;
  390. complex zz0;
  391. complex zz2;
  392. complex c;
  393. complex zz1;
  394. complex b;
  395. complex a;
  396. complex root1;
  397. complex root2;
  398. complex d;
  399. parameter real scale01;
  400. parameter complex control12;
  401. parameter real scale12;
  402. parameter complex control23;
  403. parameter real scale23;
  404. parameter complex control34;
  405. parameter real scale34;
  406. parameter complex control45;
  407. parameter real scale45;
  408.  
  409.     void init(void)
  410.     {
  411.         Var_x=0.0;
  412.         Var_y=0.0;
  413.         r=0.0;
  414.         rmin=1e20;
  415.         u=0.0;
  416.         v=0.0;
  417.         iter=0;
  418.         nlast=0;
  419.         n=0;
  420.         fac3=0;
  421.         fac4=0;
  422.         power4=0;
  423.         zh=(0,0);
  424. //
  425. // set up endpoints for the lines
  426. //
  427.         h=0.5;
  428.         ooh=1/h;
  429.         ooomh=1/(1-h);
  430.         hoomh=h/(1-h);
  431.         z0a=enterexit;
  432.         z0b=flip(enterexit);
  433.         z1=centerll;
  434.         z2=centerul;
  435.         z3=centerur;
  436.         z4=centerlr;
  437.         z5=1+flip(enterexit);
  438.     }
  439.     void loop(void)
  440.     {
  441.     }
  442.     void final(void)
  443.     {
  444.         iter=0;
  445.         zh=z*0.25+(0.5,0.5);
  446.         while ((iter<niter))
  447.         {
  448.             iter=iter+1;
  449.             Var_x=real(zh);
  450.             Var_y=imag(zh);
  451. //
  452. // lower left sub-square:  shrink, flip horizontally, rotate by -90 degrees
  453. //
  454.             if (((Var_x<h)&&(Var_y<h)))
  455.             {
  456.                 nlast=3;
  457.                 u=ooh*Var_y;
  458.                 v=ooh*Var_x;
  459. //
  460. // upper left sub-square:  just shrink
  461. //
  462.             }
  463.             else if (((Var_x<h)&&(Var_y>=h)))
  464.             {
  465.                 nlast=2;
  466.                 u=ooh*Var_x;
  467.                 v=ooomh*Var_y-hoomh;
  468. //
  469. // upper right sub-square:  shrink & flip horizontally
  470. //
  471.             }
  472.             else if (((Var_x>=h)&&(Var_y>=h)))
  473.             {
  474.                 nlast=1;
  475.                 u=ooomh-ooomh*Var_x;
  476.                 v=ooomh*Var_y-hoomh;
  477. //
  478. // lower right sub-square:  shrink, rotate by 90 degrees
  479. //
  480.             }
  481.             else if (((Var_x>=h)&&(Var_y<h)))
  482.             {
  483.                 nlast=4;
  484.                 u=ooh*Var_y;
  485.                 v=ooomh-ooomh*Var_x;
  486.             }
  487.             else
  488.             {
  489.  
  490.                 nlast=-1;
  491.                 u=Var_x;
  492.                 v=Var_y;
  493.             }
  494.             zh=u+flip(v);
  495.             n=n*4+nlast-1;
  496.         }
  497. //
  498. // determine how to start line 0-1
  499. //
  500.         z0=z0a;
  501.         c01=control01;
  502.         iter=0;
  503.         fac3=2;
  504.         fac4=1;
  505.         power4=4;
  506.         while ((iter<niter))
  507.         {
  508.             iter=iter+1;
  509.             if ((iter%2==1))
  510.             {
  511.                 if ((n%power4==fac3))
  512.                 {
  513.                     z0=z0b;
  514.                     c01=flip(control01);
  515.                 }
  516.             }
  517.             else
  518.             {
  519.  
  520.                 if ((n%power4==fac3))
  521.                 {
  522.                     z0=z0a;
  523.                     c01=control01;
  524.                 }
  525.             }
  526.             power4=4*power4;
  527.             fac4=4*fac4;
  528.             fac3=fac3+2*fac4;
  529.         }
  530. //
  531. // spline from enter to lower left sub-square
  532. //
  533.         zz0=z0;
  534.         zz2=z1;
  535.         c=c01;
  536.         if ((c==(99,99)))
  537.         {
  538.             zz1=(zz0+zz2)/2;
  539.         }
  540.         else
  541.         {
  542.  
  543.             zz1=c;
  544.         }
  545.         c=zz0-zh;
  546.         b=2*(zz1-zz0);
  547.         a=zz2-2*zz1+zz0;
  548.         if ((cabs(a)==0.0))
  549.         {
  550.             root1=-c/b;
  551.             root2=-c/b;
  552.         }
  553.         else
  554.         {
  555.  
  556.             d=sqrt(sqr(b)-4*a*c);
  557.             root1=(-b+d)/2/a;
  558.             root2=(-b-d)/2/a;
  559.         }
  560.         Var_x=real(root1);
  561.         Var_y=imag(root1);
  562.         if ((Var_x<0.0))
  563.         {
  564.             r=cabs(root1);
  565.         }
  566.         else if ((Var_x>1.0))
  567.         {
  568.             r=cabs(root1-1);
  569.         }
  570.         else
  571.         {
  572.  
  573.             r=abs(Var_y);
  574.         }
  575.         r=r/scale01;
  576.         if ((r<rmin))
  577.         {
  578.             rmin=r;
  579.         }
  580.         Var_x=real(root2);
  581.         Var_y=imag(root2);
  582.         if ((Var_x<0.0))
  583.         {
  584.             r=cabs(root2);
  585.         }
  586.         else if ((Var_x>1.0))
  587.         {
  588.             r=cabs(root2-1);
  589.         }
  590.         else
  591.         {
  592.  
  593.             r=abs(Var_y);
  594.         }
  595.         r=r/scale01;
  596.         if ((r<rmin))
  597.         {
  598.             rmin=r;
  599.         }
  600. //
  601. // spline from lower left to upper left sub-square
  602. //
  603.         zz0=z1;
  604.         zz2=z2;
  605.         c=control12;
  606.         if ((c==(99,99)))
  607.         {
  608.             zz1=(zz0+zz2)/2;
  609.         }
  610.         else
  611.         {
  612.  
  613.             zz1=c;
  614.         }
  615.         c=zz0-zh;
  616.         b=2*(zz1-zz0);
  617.         a=zz2-2*zz1+zz0;
  618.         if ((cabs(a)==0.0))
  619.         {
  620.             root1=-c/b;
  621.             root2=-c/b;
  622.         }
  623.         else
  624.         {
  625.  
  626.             d=sqrt(sqr(b)-4*a*c);
  627.             root1=(-b+d)/2/a;
  628.             root2=(-b-d)/2/a;
  629.         }
  630.         Var_x=real(root1);
  631.         Var_y=imag(root1);
  632.         if ((Var_x<0.0))
  633.         {
  634.             r=cabs(root1);
  635.         }
  636.         else if ((Var_x>1.0))
  637.         {
  638.             r=cabs(root1-1);
  639.         }
  640.         else
  641.         {
  642.  
  643.             r=abs(Var_y);
  644.         }
  645.         r=r/scale12;
  646.         if ((r<rmin))
  647.         {
  648.             rmin=r;
  649.         }
  650.         Var_x=real(root2);
  651.         Var_y=imag(root2);
  652.         if ((Var_x<0.0))
  653.         {
  654.             r=cabs(root2);
  655.         }
  656.         else if ((Var_x>1.0))
  657.         {
  658.             r=cabs(root2-1);
  659.         }
  660.         else
  661.         {
  662.  
  663.             r=abs(Var_y);
  664.         }
  665.         r=r/scale12;
  666.         if ((r<rmin))
  667.         {
  668.             rmin=r;
  669.         }
  670. //
  671. // spline from upper left to upper right sub-square
  672. //
  673.         zz0=z2;
  674.         zz2=z3;
  675.         c=control23;
  676.         if ((c==(99,99)))
  677.         {
  678.             zz1=(zz0+zz2)/2;
  679.         }
  680.         else
  681.         {
  682.  
  683.             zz1=c;
  684.         }
  685.         c=zz0-zh;
  686.         b=2*(zz1-zz0);
  687.         a=zz2-2*zz1+zz0;
  688.         if ((cabs(a)==0.0))
  689.         {
  690.             root1=-c/b;
  691.             root2=-c/b;
  692.         }
  693.         else
  694.         {
  695.  
  696.             d=sqrt(sqr(b)-4*a*c);
  697.             root1=(-b+d)/2/a;
  698.             root2=(-b-d)/2/a;
  699.         }
  700.         Var_x=real(root1);
  701.         Var_y=imag(root1);
  702.         if ((Var_x<0.0))
  703.         {
  704.             r=cabs(root1);
  705.         }
  706.         else if ((Var_x>1.0))
  707.         {
  708.             r=cabs(root1-1);
  709.         }
  710.         else
  711.         {
  712.  
  713.             r=abs(Var_y);
  714.         }
  715.         r=r/scale23;
  716.         if ((r<rmin))
  717.         {
  718.             rmin=r;
  719.         }
  720.         Var_x=real(root2);
  721.         Var_y=imag(root2);
  722.         if ((Var_x<0.0))
  723.         {
  724.             r=cabs(root2);
  725.         }
  726.         else if ((Var_x>1.0))
  727.         {
  728.             r=cabs(root2-1);
  729.         }
  730.         else
  731.         {
  732.  
  733.             r=abs(Var_y);
  734.         }
  735.         r=r/scale23;
  736.         if ((r<rmin))
  737.         {
  738.             rmin=r;
  739.         }
  740. //
  741. // spline from upper right to lower right sub-square
  742. //
  743.         zz0=z3;
  744.         zz2=z4;
  745.         c=control34;
  746.         if ((c==(99,99)))
  747.         {
  748.             zz1=(zz0+zz2)/2;
  749.         }
  750.         else
  751.         {
  752.  
  753.             zz1=c;
  754.         }
  755.         c=zz0-zh;
  756.         b=2*(zz1-zz0);
  757.         a=zz2-2*zz1+zz0;
  758.         if ((cabs(a)==0.0))
  759.         {
  760.             root1=-c/b;
  761.             root2=-c/b;
  762.         }
  763.         else
  764.         {
  765.  
  766.             d=sqrt(sqr(b)-4*a*c);
  767.             root1=(-b+d)/2/a;
  768.             root2=(-b-d)/2/a;
  769.         }
  770.         Var_x=real(root1);
  771.         Var_y=imag(root1);
  772.         if ((Var_x<0.0))
  773.         {
  774.             r=cabs(root1);
  775.         }
  776.         else if ((Var_x>1.0))
  777.         {
  778.             r=cabs(root1-1);
  779.         }
  780.         else
  781.         {
  782.  
  783.             r=abs(Var_y);
  784.         }
  785.         r=r/scale34;
  786.         if ((r<rmin))
  787.         {
  788.             rmin=r;
  789.         }
  790.         Var_x=real(root2);
  791.         Var_y=imag(root2);
  792.         if ((Var_x<0.0))
  793.         {
  794.             r=cabs(root2);
  795.         }
  796.         else if ((Var_x>1.0))
  797.         {
  798.             r=cabs(root2-1);
  799.         }
  800.         else
  801.         {
  802.  
  803.             r=abs(Var_y);
  804.         }
  805.         r=r/scale34;
  806.         if ((r<rmin))
  807.         {
  808.             rmin=r;
  809.         }
  810. //
  811. // spline from lower right sub-square to exit
  812. //
  813.         zz0=z4;
  814.         zz2=z5;
  815.         c=control45;
  816.         if ((c==(99,99)))
  817.         {
  818.             zz1=(zz0+zz2)/2;
  819.         }
  820.         else
  821.         {
  822.  
  823.             zz1=c;
  824.         }
  825.         c=zz0-zh;
  826.         b=2*(zz1-zz0);
  827.         a=zz2-2*zz1+zz0;
  828.         if ((cabs(a)==0.0))
  829.         {
  830.             root1=-c/b;
  831.             root2=-c/b;
  832.         }
  833.         else
  834.         {
  835.  
  836.             d=sqrt(sqr(b)-4*a*c);
  837.             root1=(-b+d)/2/a;
  838.             root2=(-b-d)/2/a;
  839.         }
  840.         Var_x=real(root1);
  841.         Var_y=imag(root1);
  842.         if ((Var_x<0.0))
  843.         {
  844.             r=cabs(root1);
  845.         }
  846.         else if ((Var_x>1.0))
  847.         {
  848.             r=cabs(root1-1);
  849.         }
  850.         else
  851.         {
  852.  
  853.             r=abs(Var_y);
  854.         }
  855.         r=r/scale45;
  856.         if ((r<rmin))
  857.         {
  858.             rmin=r;
  859.         }
  860.         Var_x=real(root2);
  861.         Var_y=imag(root2);
  862.         if ((Var_x<0.0))
  863.         {
  864.             r=cabs(root2);
  865.         }
  866.         else if ((Var_x>1.0))
  867.         {
  868.             r=cabs(root2-1);
  869.         }
  870.         else
  871.         {
  872.  
  873.             r=abs(Var_y);
  874.         }
  875.         r=r/scale45;
  876.         if ((r<rmin))
  877.         {
  878.             rmin=r;
  879.         }
  880. //
  881.         index=rmin;
  882.     }
  883.     void description(void)
  884.     {
  885.         this.title="Hilbert spline 2";
  886.    
  887.         niter.caption="iterations";
  888.         niter.default=0;
  889.         niter.min=0;
  890.   
  891.    
  892.         centerll.caption="lower left center";
  893.         centerll.default=(0.25,0.25);
  894.         centerll.hint="Center of the lower left sub-square. Make both coordinates between 0 & 1; use (0.25,0.25) for standard Hilbert curve.";
  895.   
  896.    
  897.         centerul.caption="upper left center";
  898.         centerul.default=(0.25,0.75);
  899.         centerul.hint="Center of the upper left sub-square. Make both coordinates between 0 & 1; use (0.25,0.75) for standard Hilbert curve.";
  900.   
  901.    
  902.         centerur.caption="upper right center";
  903.         centerur.default=(0.75,0.75);
  904.         centerur.hint="Center of the upper right sub-square. Make both coordinates between 0 & 1; use (0.75,0.75) for standard Hilbert curve.";
  905.   
  906.    
  907.         centerlr.caption="lower right center";
  908.         centerlr.default=(0.75,0.25);
  909.         centerlr.hint="Center of the lower right sub-square. Make both coordinates between 0 & 1; use (0.75,0.25) for standard Hilbert curve.";
  910.   
  911.    
  912.         enterexit.caption="enter/exit";
  913.         enterexit.default=0.25;
  914.         enterexit.min=0.0;
  915.         enterexit.max=1.0;
  916.         enterexit.hint="Where the curve enters and exits the block of 4 sub-squares. Between 0 & 1; use 0.25 for standard Hilbert curve.";
  917.   
  918.    
  919.         control01.caption="0-1 control pt";
  920.         control01.default=(99,99);
  921.         control01.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
  922.   
  923.    
  924.         control12.caption="1-2 control pt";
  925.         control12.default=(99,99);
  926.         control12.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
  927.   
  928.    
  929.         control23.caption="2-3 control pt";
  930.         control23.default=(99,99);
  931.         control23.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
  932.   
  933.    
  934.         control34.caption="3-4 control pt";
  935.         control34.default=(99,99);
  936.         control34.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
  937.   
  938.    
  939.         control45.caption="4-5 control pt";
  940.         control45.default=(99,99);
  941.         control45.hint="Both between 0 & 1; use (99,99) for average of endpoints.";
  942.   
  943.    
  944.         scale01.caption="0-1 scale";
  945.         scale01.default=1.0;
  946.         scale01.hint="Decrease to make line thinner.";
  947.   
  948.    
  949.         scale12.caption="1-2 scale";
  950.         scale12.default=1.0;
  951.         scale12.hint="Decrease to make line thinner.";
  952.   
  953.    
  954.         scale23.caption="2-3 scale";
  955.         scale23.default=1.0;
  956.         scale23.hint="Decrease to make line thinner.";
  957.   
  958.    
  959.         scale34.caption="3-4 scale";
  960.         scale34.default=1.0;
  961.         scale34.hint="Decrease to make line thinner.";
  962.   
  963.    
  964.         scale45.caption="4-5 scale";
  965.         scale45.default=1.0;
  966.         scale45.hint="Decrease to make line thinner.";
  967.   
  968.     }
  969. }
  970.  
  971.  
  972. aug01-metagon-semicircles2 {
  973. real r;
  974. real rmin;
  975. real theta;
  976. real dtheta;
  977. complex t;
  978. int iter;
  979. int iside;
  980. int kflip;
  981. complex z1;
  982. complex z2;
  983. parameter complex metagoncenter;
  984. parameter real rotdeg;
  985. parameter real length;
  986. parameter real nside;
  987. parameter real Parm_width;
  988.  
  989.     void init(void)
  990.     {
  991.         r=0.0;
  992.         rmin=1e20;
  993.         theta=0.0;
  994.         dtheta=0.0;
  995.         t=(0,0);
  996.         iter=0;
  997.         iside=0;
  998.         kflip=-1;
  999.         z1=(0,0);
  1000.         z2=(0,0);
  1001.     }
  1002.     void loop(void)
  1003.     {
  1004.     }
  1005.     void final(void)
  1006.     {
  1007.         iside=2;
  1008.         iter=0;
  1009.         z1=metagoncenter;
  1010.         theta=rotdeg*pi/180-pi;
  1011.         z2=z1+length*(cos(theta)+flip(sin(theta)));
  1012.         t=(z-z1)/(z2-z1);
  1013.         kflip=-kflip;
  1014.         if ((imag(t*kflip)>=0.0))
  1015.         {
  1016.             r=abs(cabs(t-0.5)-0.5)*cabs(z2-z1);
  1017.         }
  1018.         else
  1019.         {
  1020.  
  1021.             r=1e20;
  1022.         }
  1023.         if ((r<rmin))
  1024.         {
  1025.             rmin=r;
  1026.         }
  1027.         r=cabs(z-z1);
  1028.         if ((r<rmin))
  1029.         {
  1030.             rmin=r;
  1031.         }
  1032.         z1=z2;
  1033.         while ((iside<nside))
  1034.         {
  1035.             iside=iside+1;
  1036.             dtheta=pi-(iside-2)*pi/iside;
  1037.             iter=1;
  1038.             kflip=-1;
  1039.             while ((iter<iside))
  1040.             {
  1041.                 iter=iter+1;
  1042.                 theta=theta+dtheta;
  1043.                 z2=z1+length*(cos(theta)+flip(sin(theta)));
  1044.                 t=(z-z1)/(z2-z1);
  1045.                 kflip=-kflip;
  1046.                 if ((imag(t*kflip)>=0.0))
  1047.                 {
  1048.                     r=abs(cabs(t-0.5)-0.5)*cabs(z2-z1);
  1049.                 }
  1050.                 else
  1051.                 {
  1052.  
  1053.                     r=1e20;
  1054.                 }
  1055.                 if ((r<rmin))
  1056.                 {
  1057.                     rmin=r;
  1058.                 }
  1059.                 r=cabs(z-z1);
  1060.                 if ((r<rmin))
  1061.                 {
  1062.                     rmin=r;
  1063.                 }
  1064.                 z1=z2;
  1065.             }
  1066.         }
  1067.         if ((rmin<=Parm_width))
  1068.         {
  1069.             index=rmin/Parm_width;
  1070.         }
  1071.         else
  1072.         {
  1073.  
  1074.             solid=true;
  1075.         }
  1076.     }
  1077.     void description(void)
  1078.     {
  1079.         this.title="metagon semicircles 2";
  1080.    
  1081.         nside.caption="final # of sides";
  1082.         nside.default=8;
  1083.         nside.min=3;
  1084.   
  1085.    
  1086.         length.caption="side length";
  1087.         length.default=1.0;
  1088.   
  1089.    
  1090.         metagoncenter.caption="center";
  1091.         metagoncenter.default=(0,0);
  1092.   
  1093.    
  1094.         rotdeg.caption="rotation, deg.";
  1095.         rotdeg.default=0.0;
  1096.   
  1097.    
  1098.         Parm_width.caption="thickness";
  1099.         Parm_width.default=0.1;
  1100.   
  1101.     }
  1102. }
  1103.  
  1104.  
  1105. aug01-hilbert-spline4 {
  1106. real Var_x;
  1107. real Var_y;
  1108. real r;
  1109. real rmin;
  1110. real u;
  1111. real v;
  1112. int iter;
  1113. int nlast;
  1114. int n;
  1115. int fac3;
  1116. int fac4;
  1117. int power4;
  1118. complex zh;
  1119. real h;
  1120. real ooh;
  1121. real ooomh;
  1122. real hoomh;
  1123. complex z0a;
  1124. parameter real enterexit;
  1125. complex z0b;
  1126. complex z1;
  1127. parameter complex centerll;
  1128. complex z2;
  1129. parameter complex centerul;
  1130. complex z3;
  1131. parameter complex centerur;
  1132. complex z4;
  1133. parameter complex centerlr;
  1134. complex z5;
  1135. complex control01;
  1136. complex control12;
  1137. complex control34;
  1138. complex control45;
  1139. parameter int type34;
  1140. parameter complex control23;
  1141. parameter real xc34;
  1142. parameter int type45;
  1143. parameter real yc45;
  1144. parameter int type12;
  1145. parameter real xc12;
  1146. parameter int type01;
  1147. parameter real xc01;
  1148. parameter real niter;
  1149. complex z0;
  1150. complex c01;
  1151. complex zz0;
  1152. complex zz2;
  1153. complex zz1;
  1154. complex c;
  1155. complex b;
  1156. complex a;
  1157. complex root1;
  1158. complex root2;
  1159. complex d;
  1160. complex ztemp;
  1161.  
  1162.     void init(void)
  1163.     {
  1164.         Var_x=0.0;
  1165.         Var_y=0.0;
  1166.         r=0.0;
  1167.         rmin=1e20;
  1168.         u=0.0;
  1169.         v=0.0;
  1170.         iter=0;
  1171.         nlast=0;
  1172.         n=0;
  1173.         fac3=0;
  1174.         fac4=0;
  1175.         power4=0;
  1176.         zh=(0,0);
  1177. //
  1178. // set up endpoints for the lines
  1179. //
  1180.         h=0.5;
  1181.         ooh=1/h;
  1182.         ooomh=1/(1-h);
  1183.         hoomh=h/(1-h);
  1184.         z0a=enterexit;
  1185.         z0b=flip(enterexit);
  1186.         z1=centerll;
  1187.         z2=centerul;
  1188.         z3=centerur;
  1189.         z4=centerlr;
  1190.         z5=1+flip(enterexit);
  1191.         control01=(0,0);
  1192.         control12=(0,0);
  1193.         control34=(0,0);
  1194.         control45=(0,0);
  1195. //
  1196. // control points
  1197. //
  1198. // line 3-4
  1199. //
  1200.         if ((type34==1))
  1201.         {// normal to 2-3
  1202.             if ((imag(z3)==imag(control23)))
  1203.             {
  1204.                 Var_y=real(z3)-real(control23)+imag(z3);
  1205.             }
  1206.             else
  1207.             {
  1208.  
  1209.                 Var_y=(real(z3)-real(control23))/(imag(z3)-imag(control23))*(real(z3)-xc34)+imag(z3);
  1210.             }
  1211.         }
  1212.         else
  1213.         {
  1214.                        // tangent to 2-3
  1215.             if ((real(z3)==real(control23)))
  1216.             {
  1217.                 Var_y=2*imag(z3)-imag(control23);
  1218.             }
  1219.             else
  1220.             {
  1221.  
  1222.                 Var_y=(imag(z3)-imag(control23))/(real(z3)-real(control23))*(xc34-real(z3))+imag(z3);
  1223.             }
  1224.         }
  1225.         control34=xc34+flip(Var_y);
  1226. //
  1227. // line 4-5
  1228. //
  1229.         if ((type45==1))
  1230.         {// normal to 3-4
  1231.             if ((real(z4)==real(control34)))
  1232.             {
  1233.                 Var_x=real(z4)-imag(z4)-imag(control34);
  1234.             }
  1235.             else
  1236.             {
  1237.  
  1238.                 Var_x=-(imag(z4)-imag(control34))/(real(z4)-real(control34))*(yc45-imag(z4))+real(z4);
  1239.             }
  1240.         }
  1241.         else
  1242.         {
  1243.                        // tangent to 3-4
  1244.             if ((imag(z4)==imag(control34)))
  1245.             {
  1246.                 Var_x=2*real(z4)-real(control34);
  1247.             }
  1248.             else
  1249.             {
  1250.  
  1251.                 Var_x=(real(z4)-real(control34))/(imag(z4)-imag(control34))*(yc45-imag(z4))+real(z4);
  1252.             }
  1253.         }
  1254.         control45=Var_x+flip(yc45);
  1255. //
  1256. // line 1-2
  1257. //
  1258.         if ((type12==1))
  1259.         {// normal to 2-3
  1260.             if ((imag(z2)==imag(control23)))
  1261.             {
  1262.                 Var_y=imag(z2)-real(control23)+real(z2);
  1263.             }
  1264.             else
  1265.             {
  1266.  
  1267.                 Var_y=(real(control23)-real(z2))/(imag(control23)-imag(z2))*(real(z2)-xc12)+imag(z2);
  1268.             }
  1269.         }
  1270.         else
  1271.         {
  1272.                        // tangent to 2-3
  1273.             if ((real(z2)==real(control23)))
  1274.             {
  1275.                 Var_y=2*imag(z2)-imag(control23);
  1276.             }
  1277.             else
  1278.             {
  1279.  
  1280.                 Var_y=-(imag(control23)-imag(z2))/(real(control23)-real(z2))*(real(z2)-xc12)+imag(z2);
  1281.             }
  1282.         }
  1283.         control12=xc12+flip(Var_y);
  1284. //
  1285. // line 0-1
  1286. //
  1287.         if ((type01==1))
  1288.         {// normal to 1-2
  1289.             if ((imag(z1)==imag(control12)))
  1290.             {
  1291.                 Var_y=imag(z1)-real(control12)+real(z1);
  1292.             }
  1293.             else
  1294.             {
  1295.  
  1296.                 Var_y=(real(control12)-real(z1))/(imag(control12)-imag(z1))*(real(z1)-xc01)+imag(z1);
  1297.             }
  1298.         }
  1299.         else
  1300.         {
  1301.                        // tangent to 1-2
  1302.             if ((real(z1)==real(control12)))
  1303.             {
  1304.                 Var_y=2*imag(z1)-imag(control12);
  1305.             }
  1306.             else
  1307.             {
  1308.  
  1309.                 Var_y=-(imag(control12)-imag(z1))/(real(control12)-real(z1))*(real(z1)-xc01)+imag(z1);
  1310.             }
  1311.         }
  1312.         control01=xc01+flip(Var_y);
  1313.     }
  1314.     void loop(void)
  1315.     {
  1316.     }
  1317.     void final(void)
  1318.     {
  1319.         iter=0;
  1320.         zh=z*0.25+(0.5,0.5);
  1321.         while ((iter<niter))
  1322.         {
  1323.             iter=iter+1;
  1324.             Var_x=real(zh);
  1325.             Var_y=imag(zh);
  1326. //
  1327. // lower left sub-square:  shrink, flip horizontally, rotate by -90 degrees
  1328. //
  1329.             if (((Var_x<h)&&(Var_y<h)))
  1330.             {
  1331.                 nlast=3;
  1332.                 u=ooh*Var_y;
  1333.                 v=ooh*Var_x;
  1334. //
  1335. // upper left sub-square:  just shrink
  1336. //
  1337.             }
  1338.             else if (((Var_x<h)&&(Var_y>=h)))
  1339.             {
  1340.                 nlast=2;
  1341.                 u=ooh*Var_x;
  1342.                 v=ooomh*Var_y-hoomh;
  1343. //
  1344. // upper right sub-square:  shrink & flip horizontally
  1345. //
  1346.             }
  1347.             else if (((Var_x>=h)&&(Var_y>=h)))
  1348.             {
  1349.                 nlast=1;
  1350.                 u=ooomh-ooomh*Var_x;
  1351.                 v=ooomh*Var_y-hoomh;
  1352. //
  1353. // lower right sub-square:  shrink, rotate by 90 degrees
  1354. //
  1355.             }
  1356.             else if (((Var_x>=h)&&(Var_y<h)))
  1357.             {
  1358.                 nlast=4;
  1359.                 u=ooh*Var_y;
  1360.                 v=ooomh-ooomh*Var_x;
  1361.             }
  1362.             else
  1363.             {
  1364.  
  1365.                 nlast=-1;
  1366.                 u=Var_x;
  1367.                 v=Var_y;
  1368.             }
  1369.             zh=u+flip(v);
  1370.             n=n*4+nlast-1;
  1371.         }
  1372. //
  1373. // determine how to start line 0-1
  1374. //
  1375.         z0=z0a;
  1376.         c01=control01;
  1377.         iter=0;
  1378.         fac3=2;
  1379.         fac4=1;
  1380.         power4=4;
  1381.         while ((iter<niter))
  1382.         {
  1383.             iter=iter+1;
  1384.             if ((iter%2==1))
  1385.             {
  1386.                 if ((n%power4==fac3))
  1387.                 {
  1388.                     z0=z0b;
  1389.                     c01=flip(control01);
  1390.                 }
  1391.             }
  1392.             else
  1393.             {
  1394.  
  1395.                 if ((n%power4==fac3))
  1396.                 {
  1397.                     z0=z0a;
  1398.                     c01=control01;
  1399.                 }
  1400.             }
  1401.             power4=4*power4;
  1402.             fac4=4*fac4;
  1403.             fac3=fac3+2*fac4;
  1404.         }
  1405. //
  1406. // spline from enter to lower left sub-square
  1407. //
  1408.         zz0=z0;
  1409.         zz2=z1;
  1410.         zz1=c01;
  1411.         c=zz0-zh;
  1412.         b=2*(zz1-zz0);
  1413.         a=zz2-2*zz1+zz0;
  1414.         if ((cabs(a)==0.0))
  1415.         {
  1416.             root1=-c/b;
  1417.             root2=-c/b;
  1418.         }
  1419.         else
  1420.         {
  1421.  
  1422.             d=sqrt(sqr(b)-4*a*c);
  1423.             root1=(-b+d)/2/a;
  1424.             root2=(-b-d)/2/a;
  1425.         }
  1426.         Var_x=real(root1);
  1427.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1428.         {
  1429.             ztemp=(a*Var_x+b)*Var_x+c;
  1430.             r=cabs(ztemp);
  1431.             if ((r<rmin))
  1432.             {
  1433.                 rmin=r;
  1434.             }
  1435.         }
  1436.         Var_x=real(root2);
  1437.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1438.         {
  1439.             ztemp=(a*Var_x+b)*Var_x+c;
  1440.             r=cabs(ztemp);
  1441.             if ((r<rmin))
  1442.             {
  1443.                 rmin=r;
  1444.             }
  1445.         }
  1446. //
  1447. // spline from lower left to upper left sub-square
  1448. //
  1449.         zz0=z1;
  1450.         zz2=z2;
  1451.         zz1=control12;
  1452.         c=zz0-zh;
  1453.         b=2*(zz1-zz0);
  1454.         a=zz2-2*zz1+zz0;
  1455.         if ((cabs(a)==0.0))
  1456.         {
  1457.             root1=-c/b;
  1458.             root2=-c/b;
  1459.         }
  1460.         else
  1461.         {
  1462.  
  1463.             d=sqrt(sqr(b)-4*a*c);
  1464.             root1=(-b+d)/2/a;
  1465.             root2=(-b-d)/2/a;
  1466.         }
  1467.         Var_x=real(root1);
  1468.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1469.         {
  1470.             ztemp=(a*Var_x+b)*Var_x+c;
  1471.             r=cabs(ztemp);
  1472.             if ((r<rmin))
  1473.             {
  1474.                 rmin=r;
  1475.             }
  1476.         }
  1477.         Var_x=real(root2);
  1478.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1479.         {
  1480.             ztemp=(a*Var_x+b)*Var_x+c;
  1481.             r=cabs(ztemp);
  1482.             if ((r<rmin))
  1483.             {
  1484.                 rmin=r;
  1485.             }
  1486.         }
  1487. //
  1488. // spline from upper left to upper right sub-square
  1489. //
  1490.         zz0=z2;
  1491.         zz2=z3;
  1492.         zz1=control23;
  1493.         c=zz0-zh;
  1494.         b=2*(zz1-zz0);
  1495.         a=zz2-2*zz1+zz0;
  1496.         if ((cabs(a)==0.0))
  1497.         {
  1498.             root1=-c/b;
  1499.             root2=-c/b;
  1500.         }
  1501.         else
  1502.         {
  1503.  
  1504.             d=sqrt(sqr(b)-4*a*c);
  1505.             root1=(-b+d)/2/a;
  1506.             root2=(-b-d)/2/a;
  1507.         }
  1508.         Var_x=real(root1);
  1509.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1510.         {
  1511.             ztemp=(a*Var_x+b)*Var_x+c;
  1512.             r=cabs(ztemp);
  1513.             if ((r<rmin))
  1514.             {
  1515.                 rmin=r;
  1516.             }
  1517.         }
  1518.         Var_x=real(root2);
  1519.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1520.         {
  1521.             ztemp=(a*Var_x+b)*Var_x+c;
  1522.             r=cabs(ztemp);
  1523.             if ((r<rmin))
  1524.             {
  1525.                 rmin=r;
  1526.             }
  1527.         }
  1528. //
  1529. // spline from upper right to lower right sub-square
  1530. //
  1531.         zz0=z3;
  1532.         zz2=z4;
  1533.         zz1=control34;
  1534.         c=zz0-zh;
  1535.         b=2*(zz1-zz0);
  1536.         a=zz2-2*zz1+zz0;
  1537.         if ((cabs(a)==0.0))
  1538.         {
  1539.             root1=-c/b;
  1540.             root2=-c/b;
  1541.         }
  1542.         else
  1543.         {
  1544.  
  1545.             d=sqrt(sqr(b)-4*a*c);
  1546.             root1=(-b+d)/2/a;
  1547.             root2=(-b-d)/2/a;
  1548.         }
  1549.         Var_x=real(root1);
  1550.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1551.         {
  1552.             ztemp=(a*Var_x+b)*Var_x+c;
  1553.             r=cabs(ztemp);
  1554.             if ((r<rmin))
  1555.             {
  1556.                 rmin=r;
  1557.             }
  1558.         }
  1559.         Var_x=real(root2);
  1560.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1561.         {
  1562.             ztemp=(a*Var_x+b)*Var_x+c;
  1563.             r=cabs(ztemp);
  1564.             if ((r<rmin))
  1565.             {
  1566.                 rmin=r;
  1567.             }
  1568.         }
  1569. //
  1570. // spline from lower right sub-square to exit
  1571. //
  1572.         zz0=z4;
  1573.         zz2=z5;
  1574.         zz1=control45;
  1575.         c=zz0-zh;
  1576.         b=2*(zz1-zz0);
  1577.         a=zz2-2*zz1+zz0;
  1578.         if ((cabs(a)==0.0))
  1579.         {
  1580.             root1=-c/b;
  1581.             root2=-c/b;
  1582.         }
  1583.         else
  1584.         {
  1585.  
  1586.             d=sqrt(sqr(b)-4*a*c);
  1587.             root1=(-b+d)/2/a;
  1588.             root2=(-b-d)/2/a;
  1589.         }
  1590.         Var_x=real(root1);
  1591.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1592.         {
  1593.             ztemp=(a*Var_x+b)*Var_x+c;
  1594.             r=cabs(ztemp);
  1595.             if ((r<rmin))
  1596.             {
  1597.                 rmin=r;
  1598.             }
  1599.         }
  1600.         Var_x=real(root2);
  1601.         if (((Var_x>=0.0)&&(Var_x<=1.0)))
  1602.         {
  1603.             ztemp=(a*Var_x+b)*Var_x+c;
  1604.             r=cabs(ztemp);
  1605.             if ((r<rmin))
  1606.             {
  1607.                 rmin=r;
  1608.             }
  1609.         }
  1610. //
  1611. // balls at corners
  1612. //
  1613.         r=cabs(zh-z0);
  1614.         if ((r<rmin))
  1615.         {
  1616.             rmin=r;
  1617.         }
  1618.         r=cabs(zh-z1);
  1619.         if ((r<rmin))
  1620.         {
  1621.             rmin=r;
  1622.         }
  1623.         r=cabs(zh-z2);
  1624.         if ((r<rmin))
  1625.         {
  1626.             rmin=r;
  1627.         }
  1628.         r=cabs(zh-z3);
  1629.         if ((r<rmin))
  1630.         {
  1631.             rmin=r;
  1632.         }
  1633.         r=cabs(zh-z4);
  1634.         if ((r<rmin))
  1635.         {
  1636.             rmin=r;
  1637.         }
  1638.         r=cabs(zh-z5);
  1639.         if ((r<rmin))
  1640.         {
  1641.             rmin=r;
  1642.         }
  1643. //
  1644. // set color
  1645. //
  1646.         index=rmin;
  1647.     }
  1648.     void description(void)
  1649.     {
  1650.         this.title="Hilbert spline 4";
  1651.    
  1652.         niter.caption="iterations";
  1653.         niter.default=0;
  1654.         niter.min=0;
  1655.   
  1656.    
  1657.         centerll.caption="lower left center";
  1658.         centerll.default=(0.25,0.25);
  1659.         centerll.hint="Center of the lower left sub-square. Make both coordinates between 0 & 1; use (0.25,0.25) for standard Hilbert curve.";
  1660.   
  1661.    
  1662.         centerul.caption="upper left center";
  1663.         centerul.default=(0.25,0.75);
  1664.         centerul.hint="Center of the upper left sub-square. Make both coordinates between 0 & 1; use (0.25,0.75) for standard Hilbert curve.";
  1665.   
  1666.    
  1667.         centerur.caption="upper right center";
  1668.         centerur.default=(0.75,0.75);
  1669.         centerur.hint="Center of the upper right sub-square. Make both coordinates between 0 & 1; use (0.75,0.75) for standard Hilbert curve.";
  1670.   
  1671.    
  1672.         centerlr.caption="lower right center";
  1673.         centerlr.default=(0.75,0.25);
  1674.         centerlr.hint="Center of the lower right sub-square. Make both coordinates between 0 & 1; use (0.75,0.25) for standard Hilbert curve.";
  1675.   
  1676.    
  1677.         enterexit.caption="enter/exit";
  1678.         enterexit.default=0.25;
  1679.         enterexit.min=0.0;
  1680.         enterexit.max=1.0;
  1681.         enterexit.hint="Where the curve enters and exits the block of 4 sub-squares. Between 0 & 1; use 0.25 for standard Hilbert curve.";
  1682.   
  1683.    
  1684.         control23.caption="2-3 control pt";
  1685.         control23.default=(0.5,0.75);
  1686.         control23.hint="Both between 0 & 1.";
  1687.   
  1688.    
  1689.         type01.caption="0-1 line type";
  1690.         type01.default=0;
  1691.         type01.enum="tangent\nnormal";
  1692.         type01.hint="Relative to line 1-2.";
  1693.   
  1694.    
  1695.         type12.caption="1-2 line type";
  1696.         type12.default=0;
  1697.         type12.enum="tangent\nnormal";
  1698.         type12.hint="Relative to line 2-3.";
  1699.   
  1700.    
  1701.         type34.caption="3-4 line type";
  1702.         type34.default=0;
  1703.         type34.enum="tangent\nnormal";
  1704.         type34.hint="Relative to line 2-3.";
  1705.   
  1706.    
  1707.         type45.caption="4-5 line type";
  1708.         type45.default=0;
  1709.         type45.enum="tangent\nnormal";
  1710.         type45.hint="Relative to line 3-4.";
  1711.   
  1712.    
  1713.         xc01.caption="xc01";
  1714.         xc01.default=0.25;
  1715.   
  1716.    
  1717.         xc12.caption="xc12";
  1718.         xc12.default=0.25;
  1719.   
  1720.    
  1721.         xc34.caption="xc34";
  1722.         xc34.default=0.75;
  1723.   
  1724.    
  1725.         yc45.caption="yc45";
  1726.         yc45.default=0.25;
  1727.   
  1728.     }
  1729. }
  1730.  
  1731.  
  1732. aug01-tangent-tangent {
  1733. real dx;
  1734. parameter real nx;
  1735. real Var_x;
  1736. real Var_y;
  1737. real h;
  1738. real k;
  1739. real m;
  1740. real r;
  1741. real rmin;
  1742. int ix;
  1743. parameter real a;
  1744. parameter real b;
  1745. parameter int linetype;
  1746. parameter int updown;
  1747.  
  1748.     void init(void)
  1749.     {
  1750.         dx=pi*2/nx;
  1751.         Var_x=0.0;
  1752.         Var_y=0.0;
  1753.         h=0.0;
  1754.         k=0.0;
  1755.         m=0.0;
  1756.         r=0.0;
  1757.         rmin=1e20;
  1758.         ix=0;
  1759.     }
  1760.     void loop(void)
  1761.     {
  1762.     }
  1763.     void final(void)
  1764.     {
  1765.         ix=-1;
  1766.         Var_x=real(z);
  1767.         Var_y=imag(z);
  1768.         while ((ix<nx))
  1769.         {
  1770.             ix=ix+1;
  1771.             h=ix*dx-pi;
  1772.             k=a*tan(b*h);
  1773.             m=a*b/sqr(cos(b*h));
  1774.             if ((linetype==1))
  1775.             {// normal
  1776.                 r=abs(Var_y-k+(Var_x-h)/m)*abs(m);
  1777.             }
  1778.             else
  1779.             {
  1780.                      // tangent
  1781.                 r=abs(Var_y-k-m*(Var_x-h));
  1782.             }
  1783.             if ((updown==1))
  1784.             {
  1785.                 if (((r<rmin)&&(Var_y<k)))
  1786.                 {
  1787.                     rmin=r;
  1788.                 }
  1789.             }
  1790.             else if ((updown==2))
  1791.             {
  1792.                 if (((r<rmin)&&(Var_y>=k)))
  1793.                 {
  1794.                     rmin=r;
  1795.                 }
  1796.             }
  1797.             else
  1798.             {
  1799.  
  1800.                 if ((r<rmin))
  1801.                 {
  1802.                     rmin=r;
  1803.                 }
  1804.             }
  1805.         }
  1806.         index=rmin;
  1807.     }
  1808.     void description(void)
  1809.     {
  1810.         this.title="tangent tangent";
  1811.    
  1812.         a.caption="amplitude";
  1813.         a.default=1.0;
  1814.   
  1815.    
  1816.         b.caption="frequency";
  1817.         b.default=1.0;
  1818.   
  1819.    
  1820.         nx.caption="# x points";
  1821.         nx.default=100;
  1822.   
  1823.    
  1824.         linetype.caption="line type";
  1825.         linetype.default=0;
  1826.         linetype.enum="tangent\nnormal";
  1827.   
  1828.    
  1829.         updown.caption="above/below";
  1830.         updown.default=0;
  1831.         updown.enum="both\nbelow only\nabove only";
  1832.   
  1833.     }
  1834. }
  1835.  
  1836.  
  1837. aug01-square-trap {
  1838. real Var_x;
  1839. real Var_y;
  1840. real t;
  1841. real halfside;
  1842. parameter real side;
  1843. int iter;
  1844. int iterin;
  1845. complex z1;
  1846. complex zn;
  1847. complex temp;
  1848. parameter complex squarecenter;
  1849. parameter int colorby;
  1850.  
  1851.     void init(void)
  1852.     {
  1853.         Var_x=0.0;
  1854.         Var_y=0.0;
  1855.         t=0.0;
  1856.         halfside=side/2;
  1857.         iter=0;
  1858.         iterin=0;
  1859.         z1=(0,0);
  1860.         zn=(0,0);
  1861.     }
  1862.     void loop(void)
  1863.     {
  1864.         iter=iter+1;
  1865.         temp=z-squarecenter;
  1866.         Var_x=real(temp);
  1867.         Var_y=imag(temp);
  1868.         if (((abs(Var_x)<=halfside)&&(abs(Var_y)<=halfside)))
  1869.         {
  1870.             iterin=iterin+1;
  1871.             zn=z;
  1872.             if ((iterin==1))
  1873.             {
  1874.                 iterin=iter;
  1875.                 z1=zn;
  1876.             }
  1877.         }
  1878.     }
  1879.     void final(void)
  1880.     {
  1881.         if ((iterin==0))
  1882.         {
  1883.             solid=true;
  1884.         }
  1885.         else
  1886.         {
  1887.  
  1888.             if ((colorby==1))
  1889.             {// 1st magnitude
  1890.                 index=cabs(z1);
  1891.             }
  1892.             else if ((colorby==2))
  1893.             {// 1st angle
  1894.                 t=atan2(z1)/pi;
  1895.                 if ((t<0.0))
  1896.                 {
  1897.                     t=t+2.0;
  1898.                 }
  1899.                 index=0.5*t;
  1900.             }
  1901.             else if ((colorby==3))
  1902.             {// 1st real
  1903.                 temp=z1-squarecenter;
  1904.                 index=(real(temp)+halfside)/side;
  1905.             }
  1906.             else if ((colorby==4))
  1907.             {// 1st imag
  1908.                 temp=z1-squarecenter;
  1909.                 index=(imag(temp)+halfside)/side;
  1910.             }
  1911.             else if ((colorby==5))
  1912.             {// last magnitude
  1913.                 index=cabs(zn);
  1914.             }
  1915.             else if ((colorby==6))
  1916.             {// last angle
  1917.                 t=atan2(zn)/pi;
  1918.                 if ((t<0.0))
  1919.                 {
  1920.                     t=t+2.0;
  1921.                 }
  1922.                 index=0.5*t;
  1923.             }
  1924.             else if ((colorby==7))
  1925.             {// last real
  1926.                 temp=zn-squarecenter;
  1927.                 index=(real(temp)+halfside)/side;
  1928.             }
  1929.             else if ((colorby==8))
  1930.             {// last imag
  1931.                 temp=zn-squarecenter;
  1932.                 index=(imag(temp)+halfside)/side;
  1933.             }
  1934.             else
  1935.             {
  1936.                      // howmany
  1937.                 index=iterin/10;
  1938.             }
  1939.         }
  1940.     }
  1941.     void description(void)
  1942.     {
  1943.         this.title="square trap";
  1944.    
  1945.         squarecenter.caption="center";
  1946.         squarecenter.default=(0.0,0.0);
  1947.   
  1948.    
  1949.         side.caption="side";
  1950.         side.default=1.0;
  1951.         side.min=0.0;
  1952.   
  1953.    
  1954.         colorby.caption="color by";
  1955.         colorby.default=0;
  1956.         colorby.enum="how many\n1st mag\n1st angle\n1st real\n1st imag\nlast mag\nlast angle\nlast real\nlast imag";
  1957.   
  1958.     }
  1959. }
  1960.  
  1961.  
  1962.