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 3588 - (view) (download)

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