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

SCM Repository

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

Annotation of /branches/vis12/bugs/open/bug028.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3376 - (view) (download)

1 : glk 2334
2 :    
3 :     /*
4 :     diderotc --exec bug028.diderot && ./bug028
5 :     */
6 :    
7 :     input int sizeI = 90;
8 :     input int sizeJ = 80;
9 :     input real radius = 1.0;
10 :     input bool domain = false;
11 :     vec2 margin = [0.7,0.985];
12 :     input int which = 0;
13 :    
14 :     function vec2 idx2wrl (vec2 idx)
15 :     = [lerp(-radius, radius, 2, idx[0], sizeI-3),
16 :     lerp(radius, -radius, 2, idx[1], sizeJ-3)];
17 :    
18 :     /* bspln3 scaled to max out at 1.0 */
19 :     function real bspl (real x)
20 :     = (0.0 if |x| > 2 else (8 - 12*|x| + 6*|x|^2 - |x|^3 if |x| > 1 else (4 - 6*|x|^2 + 3*|x|^3)))/4;
21 :    
22 :     function real bump (real x) = (0.0 if x < -margin[1]
23 :     else (bspl(lerp(-2,0,-margin[1],x,-margin[0])) if x < -margin[0]
24 :     else (1.0 if x < margin[0]
25 :     else (bspl(lerp(0,2,margin[0],x,margin[1])) if x < margin[1]
26 :     else 0.0))));
27 :    
28 :     function vec2 ff (vec2 pos) {
29 :     real xx = pos[0];
30 :     real yy = pos[1];
31 :     vec2 V = [0,0];
32 :     V = ([ xx, yy] if 0 == which else
33 :     ([-xx,-yy] if 1 == which else
34 :     ([-xx, yy] if 2 == which else
35 :     ([ xx,-yy] if 3 == which else
36 :     ([ yy, xx] if 4 == which else
37 :     ([-yy,-xx] if 5 == which else
38 :     ([-yy, xx] if 6 == which else
39 :     ([ yy,-xx]))))))));
40 :     return bump(xx)*bump(yy)*V;
41 :     }
42 :    
43 :     vec2 oo = idx2wrl([0,0]);
44 :     vec2 uu = idx2wrl([1,0]) - idx2wrl([0,0]);
45 :     vec2 vv = idx2wrl([0,1]) - idx2wrl([0,0]);
46 :    
47 :     // rows appear as contiguous vectors
48 :     tensor[2,3] i2w = [[uu[0], vv[0], oo[0]],
49 :     [uu[1], vv[1], oo[1]]];
50 :    
51 :     strand sample (int ii, int jj) {
52 :     vec3 posi = [ii, jj, 1];
53 :     // BUG: 2-by-3 times 3-vector multiply not implemented?
54 : jhr 3376 /*
55 : glk 2334 uncaught exception Fail [Fail: unsupported matrix-vector multiply]
56 :     raised at common/phase-timer.sml:76.50-76.52
57 :     raised at common/phase-timer.sml:76.50-76.52
58 :     raised at c-util/tree-to-c.sml:185.30-185.71
59 :     */
60 :     vec2 posw = i2w•posi;
61 :     output vec2 out = [0,0];
62 :    
63 :     update {
64 :     if (ii == 0 && jj == 0) {
65 :     //print("unu save -i out.nrrd -f nrrd -o out.nhdr\n");
66 :     print("space dimension: 2\n");
67 :     print("space directions: none (", uu[0], ",", uu[1], ") (", vv[0], ",", vv[1], ")\n");
68 :     print("space origin: (", oo[0], ",", oo[1], ")\n");
69 :     }
70 :     out = posw if domain else ff(posw);
71 :     stabilize;
72 :     }
73 :     }
74 :    
75 :     initially [sample(ii, jj) | jj in 0..sizeJ-1, ii in 0..sizeI-1];
76 :     // slow ---> to --> fast
77 :     // in both strand creation order, and
78 :     // saving output raster order

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