// 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) ];
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: } stabilize; } } initially [ sample(r, c) | r in 0..(imgSize-1), c in 0..(imgSize-1) ];