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

SCM Repository

[diderot] View of /branches/vis12/bugs/resolved/bug012.diderot
ViewVC logotype

View of /branches/vis12/bugs/resolved/bug012.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2184 - (download) (annotate)
Sun Feb 24 01:59:49 2013 UTC (6 years, 6 months ago) by jhr
File size: 1926 byte(s)
  Fix issues in bug012.diderot.
/*
  This would be a hyperLIC program, but the tensor field and eigenvector
  stuff has been removed. Generate and process output out.nrrd with:

unu project  -i out.nrrd -a 2 -m sum | unu quantize -b 8 -min 1% -max 1% -o hlic.png

*/

int imgSize = 400;
real hh = 0.4;    // step size of integration
int stepNum = 30;  // take at most this many steps

/*
// BUG: this works, but isn't what the algorithm needs:
function vec2 align (vec2 vv, vec2 ref) = vv;
*/


// BUG: this is what the algorithm needs, but it generates:
// uncaught exception Fail [Fail: no binding for _t0132 in environment]
//   raised at common/phase-timer.sml:76.50-76.52
//   raised at translate/translate.sml:380.110-380.112
//   raised at translate/translate.sml:320.29-320.31
//   raised at translate/translate.sml:56.22-58.5
// FIXED
//function vec2 align (vec2 vv, vec2 ref) = (vv if (vv•ref > 0) else -vv);


// BUG: another way of expressing what is needed, but it generates:
// [bug008.diderot:34.3-37.0] Error: Missing return statement in tail position of function align
// Weirdly, if you comment out the "if (ret•ref < 0)" block, it works okay
// FIXED
function vec2 align (vec2 vv, vec2 ref) {
  vec2 ret = vv;
  if (ret•ref < 0) {
    ret = -ret;
  }
  return ret;
}

strand HLIC (real sign, vec2 pos0) {
    vec2 lastdir = pos0;
    vec2 pos = pos0;
    vec2 step = [0.0,0.0];
    output real out = 0.0;
    real sum = 0.0;
    int stepIdx = 0;
    vec2 dir = [0.0,0.0];

    update {
      dir = align(pos, lastdir);
      pos += hh*dir;
      sum += |pos|;
      stepIdx += 1;
      lastdir = dir;
      if (stepIdx == stepNum) {
        stabilize;
      }
    }

    stabilize {
      out = sum;
    }
}

initially [ HLIC(lerp(-1, 1, 0, si, 1),
                 [lerp(0.0, 81.0, -0.5, xi, imgSize-0.5),
                  lerp(0.0, 81.0, -0.5, yi, imgSize-0.5)])
            | si in 0..1, yi in 0..imgSize-1, xi in 0..imgSize-1];

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