Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /tests/glk-tests/new/isodense.diderot
ViewVC logotype

View of /tests/glk-tests/new/isodense.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (download) (annotate)
Tue Sep 27 20:54:47 2016 UTC (2 years, 9 months ago) by glk
File size: 1535 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
#version 2

field#1(2)[] F = c4hexic ⊛ load_image("hand.nrrd");

input vec2 cent = [0,0];
input real hght = 2;
input int size0 = 6;
input int size1 = 4;
input int pad = 0;

real wdth = hght*size0/size1;

vec2 spc = [wdth/(size0-1), hght/(size1-1)];
vec2 dir0 = [spc[0], 0.0];
vec2 dir1 = [0.0, spc[1]];
vec2 orig = cent - (dir0*(size0-1) + dir1*(size1-1))/2.0;

vec2 porig = orig - pad*(dir0 + dir1);
int psize0 = size0 + 2*pad;
int psize1 = size1 + 2*pad;

input int stepsMax = 10;
real epsilon = 0.0001;
input int prune = 10;

strand isod(int ID, int ui, int vi) {
   output vec2 x = porig + ui*dir0 + vi*dir1;
   int steps = 0;
   update {
      if ( (ID/prune)*prune != ID ) {
         die;
      }
      if (0 == steps && 0 == ui && 0 == vi) {
         vec2 imin = orig - (dir0 + dir1)*0.5;
         vec2 imax = orig + dir0*(size0-0.5) + dir1*(size1-0.5);
         print(imin[0], " ", imin[1], " ", imax[0], " ", imax[1], "\n");
      }
      // Stop if we're no longer inside or taken too many steps.
      if (!inside(x, F) || steps > stepsMax) {
         die;
      }

      // subsequent expressions are undefined if |∇F| is zero
      if (|∇F(x)| == 0.0)
         die;

      // the Newton-Raphson step
       vec2 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;

      // we've converged if the change is small enough
      if (|delta| < epsilon)
         stabilize;
      x -= delta;
      steps += 1;
   }
}

create_collection { isod(ui + size0*vi,
                 ui, vi) | vi in 0..(psize1-1), ui in 0..(psize0-1) }

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0