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

SCM Repository

[diderot] Annotation of /branches/vis12/bugs/resolved/bug026.diderot
ViewVC logotype

Annotation of /branches/vis12/bugs/resolved/bug026.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2334 - (view) (download)
Original Path: branches/vis12/bugs/open/bug026.diderot

1 : glk 2334
2 :     /*
3 :     $DDRO_HOME/branches/vis12/bin/diderotc --exec bug026.diderot \
4 :     && ./bug026 \
5 :     && unu jhisto -i x.nrrd -b 800 800 -min 0 0 -max 1 1 \
6 :     | unu 2op neq - 0 \
7 :     | unu quantize -b 8 -o bug026.png
8 :     */
9 :    
10 :     input real isoval = 0.5;
11 :     field#1(2)[] F = ctmr ⊛ image("../data/ddro.nrrd") - isoval;
12 :    
13 :     int grid = 150;
14 :     int stepsMax = 10;
15 :     real epsilon = 0.000001;
16 :    
17 :     strand RootFind(vec2 x0) {
18 :     output vec2 x = x0;
19 :     int steps = 0;
20 :     update {
21 :     // Stop if we're no longer inside or taken too many steps.
22 :     if (!inside(x, F) || steps > stepsMax)
23 :     die;
24 :     /* BUG: this code generates
25 :     error converting OffsetField
26 :     uncaught exception Fail [Fail: bogus operator OffsetField]
27 :     raised at common/phase-timer.sml:76.50-76.52
28 :     raised at common/phase-timer.sml:76.50-76.52
29 :     raised at high-to-mid/high-to-mid.sml:297.85-297.87
30 :     raised at high-to-mid/high-to-mid.sml:294.32-294.78
31 :     The code can be fixed by replacing all "∇F(x)" with uses of a
32 :     new variable "vec2 grad = ∇F(x)", but why should that be needed? */
33 :     if (|∇F(x)| == 0.0)
34 :     die;
35 :     // the Newton-Raphson step
36 :     vec2 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;
37 :     // we've converged if the change is small enough
38 :     if (|delta| < epsilon)
39 :     stabilize;
40 :     x -= delta;
41 :     steps += 1;
42 :     }
43 :     }
44 :    
45 :     initially { RootFind([lerp(0, 1, -0.5, ui, grid-0.5),
46 :     lerp(0, 1, -0.5, vi, grid-0.5)])
47 :     | vi in 0..(grid-1), ui in 0..(grid-1) };
48 :    
49 :     /*
50 :     different in 3D:
51 :     vec2 -> vec3
52 :     field#1(2)[] F -> field#1(3)[] F
53 :     initially over 3D grid
54 :     */

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