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

SCM Repository

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

View of /branches/pure-cfg/test/zslice-k1k2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 814 - (download) (annotate)
Tue Apr 12 18:02:35 2011 UTC (8 years, 6 months ago) by jhr
File size: 1779 byte(s)
  Remove some HEYs
// zslice-k1k2.diderot
// demo of implicit surface curvature computation

int dataSize = 11;
int imgSize = 200;
vec3 orig = [0.0, 0.0, 5.0];
vec3 cVec = [0.0, 1.0, 0.0];
vec3 rVec = [1.0, 0.0, 0.0];
image(3)[] img = load("../data/zimg11.nrrd");
field#2(3)[] F = img ⊛ bspln3;

strand sample (int row, int col)
{
    real rr = lerp(-0.5, real(dataSize)-0.5, -0.5, real(row), real(imgSize)-0.5);
    real cc = lerp(-0.5, real(dataSize)-0.5, -0.5, real(col), real(imgSize)-0.5);
    vec3 pos = orig + rr*rVec + cc*cVec;
    output vec2 k1k2 = [0.0,0.0]; 

    update
    {
        if (inside (pos,F)) {
           // HEY want: (syntax from matlab) tensor[3,3] G = zeros(3,3);  
           tensor[3,3] G = [[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]];
           vec3 g = -∇F@pos;
           if (|g| > 0.0) {
              tensor[3,3] H = ∇(∇F)@pos;
              vec3 n = normalize(g);
              // HEY NEED: (matlab) "eye(3)", or (pylab) "identity(3)"
              // HEY NEED: tensor product of two vectors u⊗v;
              // should be: tensor[3,3] P = identity(3) - n⊗n;
              tensor[3,3] P = I; // fake
              // HEY NEED: matrix • matrix multiply 
              // should be: G = (P•H•P)/|g|;
              G = P•H•P; // fake
           }
           // HEY NEED: norm works on tensor[3,3], e.g. |G|
           real Gnorm = 2.0*trace(G); // fake; should be |G|
           // HEY want: x^y == x*x*... for integral y < 5 and pow(x,y) otherwise
           real disc = sqrt(2.0*Gnorm*Gnorm - trace(G)*trace(G));
           // should be: real disc = sqrt(2*|G|^2 - trace(G)^2);
           k1k2 = [trace(G) + disc, trace(G) - disc]/2.0;
	}
        stabilize;
    }
}

initially [ sample(r, c) | r in 0..(imgSize-1), c in 0..(imgSize-1) ];

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