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

SCM Repository

[diderot] View of /branches/vis15/src/tests/glk-tests/new/ridge2d.diderot
ViewVC logotype

View of /branches/vis15/src/tests/glk-tests/new/ridge2d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4497 - (download) (annotate)
Sat Sep 3 14:12:36 2016 UTC (2 years, 6 months ago) by jhr
File size: 1404 byte(s)
  working on merge: updating tests with new version 2 syntax
#version 2

// 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_image("../data/ddro-80.nrrd");
input int stepsMax ("maximum number of steps") = 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;
        } else {
            pos += delta;
            steps += 1;
            travel += |delta|;
        }
    }
}

create_collection { 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