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

SCM Repository

[diderot] Annotation of /branches/charisee/ertest/vispaper/iso3d/iso3d.diderot
ViewVC logotype

Annotation of /branches/charisee/ertest/vispaper/iso3d/iso3d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2899 - (view) (download)

1 : glk 2899
2 :     /*
3 :    
4 :     ../../../bin/diderotc iso3d.diderot \
5 :     && ./iso3d \
6 :     && unu crop -i iso3d.txt -min 0 0 -max 1 M | \
7 :     unu jhisto -b 600 600 -min -1.2 -1.2 -max 1.2 1.2 -t float | \
8 :     unu 1op log1p | \
9 :     unu quantize -b 8 -o iso3d.png \
10 :     && open iso3d.png
11 :    
12 :     */
13 :    
14 :     field#2(3)[] V= bspln3 ⊛ load("parab0.nrrd");
15 :     field#2(3)[] U= bspln3 ⊛ load("parab1.nrrd");
16 :    
17 :     // isosurface of V itself: works
18 :     //field#1(3)[] F = V - 0.5;
19 :    
20 :     // isosurface of |∇V|: works
21 :     //field#1(3)[] F = |∇V| - 1;
22 :    
23 :     // lifting vector op to constant vector and field: does not work?
24 :     field#1(3)[] F = ∇V • [1,0,0];
25 :     //field#1(3)[] F = |∇V - [1,0,0]|;
26 :    
27 :     // lifting vector op to two fields
28 :     // field#1(3)[] F = ∇V • ∇U - 1; // does work
29 :     //field#1(3)[] F = |∇V - ∇U| - 0.01; // never finishes compiling?
30 :    
31 :     int grid = 30;
32 :     int stepsMax = 10;
33 :     real epsilon = 0.000001;
34 :    
35 :     strand RootFind(real xi,real xj, real xk) {
36 :     output vec3 x = [xi,xj,xk];
37 :     int steps = 0;
38 :     update {
39 :     // Stop if we're no longer inside or taken too many steps.
40 :     if (!inside(x, V) || steps > stepsMax)
41 :     die;
42 :     // subsequent expressions are undefined if |∇F| is zero
43 :     if (|∇F(x)| == 0.0)
44 :     die;
45 :     // the Newton-Raphson step
46 :     vec3 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;
47 :     // we've converged if the change is small enough
48 :     if (|delta| < epsilon)
49 :     stabilize;
50 :     x -= delta;
51 :     steps += 1;
52 :     }
53 :     }
54 :    
55 :     initially { RootFind(lerp(-2, 2, -0.5, ui, grid-0.5),
56 :     lerp(-2, 2, -0.5, vi, grid-0.5),
57 :     lerp(-2, 2, -0.5, wi, grid-0.5))
58 :     | wi in 0..(grid-1), vi in 0..(grid-1), ui in 0..(grid-1) };

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