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

SCM Repository

[diderot] View of /branches/pure-cfg/test/lic.diderot
ViewVC logotype

View of /branches/pure-cfg/test/lic.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 935 - (download) (annotate)
Fri Apr 22 13:22:41 2011 UTC (8 years, 2 months ago) by glk
File size: 1309 byte(s)
demo of line integral convolution
// lic.diderot
// 
// simple demo of the line integral convolution (LIC) method
// of vector field viz
//
// process output with:
// unu reshape -i mip.txt -s 300 200 | unu quantize -b 8  -o lic.png
//
// NOTE: this computes a streamline along only one direction of 
// field at starting point; it would be more correct to go 
// in both directions (both upstream and downstream)

int imgSizeX = 300;
int imgSizeY = 200;
real h = 0.01;
int stepNum = 20;

image(2)[2] Vimg = load("../data/vorttest.nrrd");
field#1(2)[2] V = Vimg ⊛ ctmr;
image(2)[] Rimg = load("../data/vorttest-rand.nrrd");
field#0(2)[] R = Rimg ⊛ tent;

strand LIC (int xi, int yi) {
    real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
    real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
    vec2 pos0 = [xx,yy];
    vec2 pos = pos0;
    output real avg = 0.0;
    int step = 0;

    update {
        avg = avg + R(pos);
        // pos = pos + h*V(pos);         // Euler step
        pos = pos + h*V(pos + 0.5*h*V(pos));  // RK2 step
        step = step + 1;
        if (step == stepNum) {
          // modulate output by velocity at initial position
          avg = |V(pos0)|*avg/real(stepNum);
          stabilize;
        }
    }
}

initially [ LIC(xi, yi) | yi in 0..(imgSizeY-1), xi in 0..(imgSizeX-1) ];

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