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

SCM Repository

[diderot] Annotation of /branches/vis15/src/tests/glk-tests/new/isodense.diderot
ViewVC logotype

Annotation of /branches/vis15/src/tests/glk-tests/new/isodense.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4497 - (view) (download)

1 : jhr 4497 #version 2
2 : jhr 3588
3 : jhr 4497 field#1(2)[] F = c4hexic ⊛ load_image("hand.nrrd");
4 : jhr 3588
5 :     input vec2 cent = [0,0];
6 :     input real hght = 2;
7 :     input int size0 = 6;
8 :     input int size1 = 4;
9 :     input int pad = 0;
10 :    
11 :     real wdth = hght*size0/size1;
12 :    
13 :     vec2 spc = [wdth/(size0-1), hght/(size1-1)];
14 :     vec2 dir0 = [spc[0], 0.0];
15 :     vec2 dir1 = [0.0, spc[1]];
16 :     vec2 orig = cent - (dir0*(size0-1) + dir1*(size1-1))/2.0;
17 :    
18 :     vec2 porig = orig - pad*(dir0 + dir1);
19 :     int psize0 = size0 + 2*pad;
20 :     int psize1 = size1 + 2*pad;
21 :    
22 :     input int stepsMax = 10;
23 :     real epsilon = 0.0001;
24 :     input int prune = 10;
25 :    
26 :     strand isod(int ID, int ui, int vi) {
27 :     output vec2 x = porig + ui*dir0 + vi*dir1;
28 :     int steps = 0;
29 :     update {
30 :     if ( (ID/prune)*prune != ID ) {
31 :     die;
32 :     }
33 :     if (0 == steps && 0 == ui && 0 == vi) {
34 :     vec2 imin = orig - (dir0 + dir1)*0.5;
35 :     vec2 imax = orig + dir0*(size0-0.5) + dir1*(size1-0.5);
36 :     print(imin[0], " ", imin[1], " ", imax[0], " ", imax[1], "\n");
37 :     }
38 :     // Stop if we're no longer inside or taken too many steps.
39 :     if (!inside(x, F) || steps > stepsMax) {
40 :     die;
41 :     }
42 :    
43 :     // subsequent expressions are undefined if |∇F| is zero
44 :     if (|∇F(x)| == 0.0)
45 :     die;
46 :    
47 :     // the Newton-Raphson step
48 :     vec2 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;
49 :    
50 :     // we've converged if the change is small enough
51 :     if (|delta| < epsilon)
52 :     stabilize;
53 :     x -= delta;
54 :     steps += 1;
55 :     }
56 :     }
57 :    
58 : jhr 4497 create_collection { isod(ui + size0*vi,
59 : jhr 3588 ui, vi) | vi in 0..(psize1-1), ui in 0..(psize0-1) }

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