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

SCM Repository

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

Annotation of /branches/vis12/bugs/bug008.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2175 - (view) (download)

1 : glk 2175 /*
2 :     This would be a hyperLIC program, but the tensor field and eigenvector
3 :     stuff has been removed. Generate and process output out.nrrd with:
4 :    
5 :     unu project -i out.nrrd -a 2 -m sum | unu quantize -b 8 -min 1% -max 1% -o hlic.png
6 :    
7 :     */
8 :    
9 :     int imgSize = 400;
10 :     real hh = 0.4; // step size of integration
11 :     int stepNum = 30; // take at most this many steps
12 :    
13 :     /*
14 :     // BUG: this works, but isn't what the algorithm needs:
15 :     function vec2 align (vec2 vv, vec2 ref) = vv;
16 :     */
17 :    
18 :    
19 :     // BUG: this is what the algorithm needs, but it generates:
20 :     // uncaught exception Fail [Fail: no binding for _t0132 in environment]
21 :     // raised at common/phase-timer.sml:76.50-76.52
22 :     // raised at translate/translate.sml:380.110-380.112
23 :     // raised at translate/translate.sml:320.29-320.31
24 :     // raised at translate/translate.sml:56.22-58.5
25 :     function vec2 align (vec2 vv, vec2 ref) = (vv if (vv•ref > 0) else -vv);
26 :    
27 :    
28 :     /*
29 :     // BUG: another way of expressing what is needed, but it generates:
30 :     // [bug008.diderot:34.3-37.0] Error: Missing return statement in tail position of function align
31 :     // Weirdly, if you comment out the "if (ret•ref < 0)" block, it works okay
32 :     function vec2 align (vec2 vv, vec2 ref) {
33 :     vec2 ret = vv;
34 :     if (ret•ref < 0) {
35 :     ret = -ret;
36 :     }
37 :     return ret;
38 :     }
39 :     */
40 :    
41 :     strand HLIC (real sign, vec2 pos0) {
42 :     vec2 lastdir = pos0;
43 :     vec2 pos = pos0;
44 :     vec2 step = [0.0,0.0];
45 :     output real out = 0.0;
46 :     real sum = 0.0;
47 :     int stepIdx = 0;
48 :     vec2 dir = [0.0,0.0];
49 :    
50 :     update {
51 :     dir = align(pos, lastdir);
52 :     pos += hh*dir;
53 :     sum += |pos|;
54 :     stepIdx += 1;
55 :     lastdir = dir;
56 :     if (stepIdx == stepNum) {
57 :     stabilize;
58 :     }
59 :     }
60 :    
61 :     stabilize {
62 :     out = sum;
63 :     }
64 :     }
65 :    
66 :     initially [ HLIC(lerp(-1, 1, 0, si, 1),
67 :     [lerp(0.0, 81.0, -0.5, xi, imgSize-0.5),
68 :     lerp(0.0, 81.0, -0.5, yi, imgSize-0.5)])
69 :     | si in 0..1, yi in 0..imgSize-1, xi in 0..imgSize-1];

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