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

SCM Repository

[diderot] View of /branches/vis12/bugs/open/bug039.diderot
ViewVC logotype

View of /branches/vis12/bugs/open/bug039.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2928 - (download) (annotate)
Wed Mar 4 01:39:07 2015 UTC (4 years, 9 months ago) by glk
File size: 2664 byte(s)
sigh
/*
uncaught exception UnequalLengths [UnequalLengths]
  raised at common/phase-timer.sml:76.50-76.52
  raised at common/phase-timer.sml:76.50-76.52
  raised at Basis/Implementation/list-pair.sml:55.23-55.37
*/

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) {
//  real x = pos[0];
//  real y = pos[1];
//  real z = pos[2];
    if (1 == which) {
      return pos•pos/2;
    } else {
      real sig = 0.2;
      real aa = 2.066365677/(sig^3);
      real bb = 3*2.066365677/sig;
      real rr = |pos|;
      real cap = -aa*rr*rr + bb;
      real gss = exp(-rr*rr/(2*sig*sig))/(sqrt(2*π)*sig);
      return cap if (rr < sig) else gss;
    }
}

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