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

SCM Repository

[diderot] View of /branches/vis12/test/ridge2d.diderot
ViewVC logotype

View of /branches/vis12/test/ridge2d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1685 - (download) (annotate)
Sun Jan 22 15:23:36 2012 UTC (7 years, 10 months ago) by jhr
File size: 1395 byte(s)
  Create a branch to implement things that we need for the Vis 2012 paper
// ridge2d
//
// Process output with:
// unu jhisto -i ridge2d.txt -b 512 512 -min 0 0 -max 1 1 | unu 2op neq - 0 | unu quantize -b 8 -o ridge2d.png

int gridSize = 200;
field#2(2)[] F = bspln3 ⊛ load("../data/ddro-80.nrrd");
input int stepsMax = 20;
real epsilon = 0.0001;
real travelMax = 0.1;

strand sample (int ui, int vi) {
    output vec2 pos = [lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5),
                       lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)];
    int steps = 0;
    real travel = 0.0;
    update {
        if (!inside(pos, F) || steps > stepsMax || travel > travelMax) {
	    die;
        }
        real gmag = |∇F(pos)|;
        if (gmag == 0.0) {    // can't compute step if |∇F|, so have to bail
	    die;
        }
        tensor[2,2] hess = ∇⊗∇F(pos);
        real{2} eval = evals(hess);
        vec2{2} evec = evecs(hess);
        real fdd = evec{1}•∇F(pos);
        real sdd = evec{1}•hess•evec{1};
        vec2 delta = (0.001 if sdd >= 0.0 else -fdd/sdd)*evec{1};
        if (|delta| < epsilon) {
            if (eval{1} < -800.0) {
               stabilize;
            }
            die;
        } // BUG: can't have:  else {
            pos += delta;
            steps += 1;
            travel += |delta|;
        // BUG: can't have:    }
    }
}

initially { sample(ui, vi) | vi in 0..(gridSize-1), ui in 0..(gridSize-1) };


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