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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 824 - (view) (download)

1 : glk 805
2 :     // zslice-k1k2.diderot
3 :     // demo of implicit surface curvature computation
4 :    
5 :     int dataSize = 11;
6 :     int imgSize = 200;
7 :     vec3 orig = [0.0, 0.0, 5.0];
8 :     vec3 cVec = [0.0, 1.0, 0.0];
9 :     vec3 rVec = [1.0, 0.0, 0.0];
10 :     image(3)[] img = load("../data/zimg11.nrrd");
11 :     field#2(3)[] F = img ⊛ bspln3;
12 :    
13 :     strand sample (int row, int col)
14 :     {
15 :     real rr = lerp(-0.5, real(dataSize)-0.5, -0.5, real(row), real(imgSize)-0.5);
16 :     real cc = lerp(-0.5, real(dataSize)-0.5, -0.5, real(col), real(imgSize)-0.5);
17 :     vec3 pos = orig + rr*rVec + cc*cVec;
18 :     output vec2 k1k2 = [0.0,0.0];
19 :    
20 :     update
21 :     {
22 :     if (inside (pos,F)) {
23 : jhr 824 tensor[3,3] G = zeros[3,3];
24 : glk 805 vec3 g = -∇F@pos;
25 :     if (|g| > 0.0) {
26 :     tensor[3,3] H = ∇(∇F)@pos;
27 :     vec3 n = normalize(g);
28 : jhr 824 tensor[3,3] P = identity[3] - n⊗n;
29 :     G = (P•H•P)/|g|;
30 : glk 805 }
31 :     // HEY NEED: norm works on tensor[3,3], e.g. |G|
32 :     real Gnorm = 2.0*trace(G); // fake; should be |G|
33 :     // HEY want: x^y == x*x*... for integral y < 5 and pow(x,y) otherwise
34 : jhr 824 real disc = sqrt(2.0*Gnorm^2 - trace(G)^2);
35 : glk 805 // should be: real disc = sqrt(2*|G|^2 - trace(G)^2);
36 :     k1k2 = [trace(G) + disc, trace(G) - disc]/2.0;
37 :     }
38 :     stabilize;
39 :     }
40 :     }
41 :    
42 :     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