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

SCM Repository

[diderot] View of /tests/glk-tests/orig/fsamp.diderot
ViewVC logotype

View of /tests/glk-tests/orig/fsamp.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: 2823 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
input int sz0 = 30;
input int sz1 = 30;
input int sz2 = 30;
input real width = 4;
input int which = 1;
vec3 spc = [width/(sz0-1), width/(sz1-1), width/(sz2-1)];

input vec3 pp = [0.2,0.2,0.2];
vec4 qq = normalize([pp[0],pp[1],pp[2],1.0]);
tensor[3,3] rot = [[qq[0]*qq[0] + qq[1]*qq[1] - qq[2]*qq[2] - qq[3]*qq[3],
                    2*(qq[1]*qq[2] - qq[0]*qq[3]),
                    2*(qq[1]*qq[3] + qq[0]*qq[2])],
                   [2*(qq[1]*qq[2] + qq[0]*qq[3]),
                    qq[0]*qq[0] - qq[1]*qq[1] + qq[2]*qq[2] - qq[3]*qq[3],
                    2*(qq[2]*qq[3] - qq[0]*qq[1])],
                   [2*(qq[1]*qq[3] - qq[0]*qq[2]),
                    2*(qq[2]*qq[3] + qq[0]*qq[1]),
                    qq[0]*qq[0] - qq[1]*qq[1] - qq[2]*qq[2] + qq[3]*qq[3]]];
vec3 xdir = rot•[spc[0], 0.0, 0.0];
vec3 ydir = rot•[0.0, spc[1], 0.0];
vec3 zdir = rot•[0.0, 0.0, spc[2]];
vec3 orig = -(xdir*(sz0-1) + ydir*(sz1-1) + zdir*(sz2-1))/2;

function real func(vec3 pos) {
    if (1 == which) {
      return pos•pos/2;
    } else if (2 == which) {
      // a C1 union of a downward parabala (constant hessian)
      // and a gaussian (hessian goes to zer0)
      real sig = 0.7;
      real aa = 0.1209853623/(sig^3);
      real bb = 3*0.1209853623/sig;
      real rr = |pos|;
      real cap = -aa*rr*rr + bb;
      real gss = exp(-rr*rr/(2*sig*sig))/(sqrt(2*π)*sig);
      // the rr < sig conditional won't work, so use lerp instead
      real ww =  clamp(0, 1, lerp(0, 1, -1, 100*(rr-sig), 1));
      real ret = (1-ww)*cap + ww*gss;
      return ret;
    } else if (3 == which) {
       real x = pos[0];
       real y = pos[1];
       return atan2(y,x);
    } else {
       return 2*pos[0] + erf(10*(0.8-|pos|));
    }
}

strand sample(int xi, int yi, int zi) {
  output real vv = 0;
  update {
    if (0 == xi && 0 == yi && 0 == zi) {
      print("NRRD0004\n");
      print("# Complete NRRD file format specification at:\n");
      print("# http://teem.sourceforge.net/nrrd/format.html\n");
      print("type: float\n");
      print("dimension: 3\n");
      print("sizes: ", sz0, " ", sz1, " ", sz2, "\n");
      print("kinds: space space space\n");
      print("endian: little\n");
      print("encoding: raw\n");
      print("space dimension: 3\n");
      print("space directions: (", xdir[0], ",", xdir[1], ",", xdir[2],
                            ") (", ydir[0], ",", ydir[1], ",", ydir[2],
                            ") (", zdir[0], ",", zdir[1], ",", zdir[2], ")\n");
      print("space origin: (", orig[0], ",", orig[1], ",", orig[2], ")\n");
      print("data file: vv.nrrd\n");
      print("byte skip: -1\n");
    }
    vec3 xyz  = orig + xi*xdir + yi*ydir + zi*zdir;
    vv = func(xyz);
    stabilize;
  }
}
initially [ sample(xi, yi, zi) | zi in 0..(sz2-1), yi in 0..(sz1-1), xi in 0..(sz0-1) ];

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