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 824 - (download) (annotate)
Thu Apr 14 15:54:24 2011 UTC (8 years, 4 months ago) by jhr
File size: 1364 byte(s)
  Some debugging and added "^" as power operator.
// 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)) {
           tensor[3,3] G = zeros[3,3];
           vec3 g = -∇F@pos;
           if (|g| > 0.0) {
              tensor[3,3] H = ∇(∇F)@pos;
              vec3 n = normalize(g);
              tensor[3,3] P = identity[3] - n⊗n;
              G = (P•H•P)/|g|;
           }
           // 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^2 - trace(G)^2);
           // 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