// For testing issues with adding or multiplying a scalar constant // and a scalar field: // NOTE: There are 6 different possible definitions of field GG below; // uncomment one at a time. The definition inside "update" is the // only one that isn't a compiler bug, but as explained its not where // "GG = FF - sclr" would actually be used. // Process output with: // unu jhisto -i pos.nrrd -b 200 200 -min 0 0 -max 1 1 | unu 2op neq - 0 | unu quantize -b 8 -o iso2d.png input real sclr = 1.0; int gridSize = 200; int stepsMax = 10; real epsilon = 0.001; field#1(2)[] FF = ctmr ⊛ image("data/ddro.nrrd"); strand sample (vec2 pos0) { output vec2 pos = pos0; int steps = 0; /* ** BUG: Defining GG here doesn't work: ** uncaught exception Fail [Fail: probe: bogus field binding GG0185 = RHS(self.GG)] raised at common/phase-timer.sml:76.50-76.52 raised at common/phase-timer.sml:76.50-76.52 raised at high-il/normalize.sml:244.18-246.11 */ field#1(2)[] GG = FF - sclr; update { vec2 grad = ∇GG(pos); if (|grad| == 0) { die; } vec2 delta = -(GG(pos)/|grad|)*normalize(grad); if (|delta| < epsilon) { stabilize; } pos += delta; steps += 1; if (!inside(pos, GG) || steps > stepsMax) { die; } } } initially { sample([lerp(0.0, 1.0, -0.5, real(ui), real(gridSize)-0.5), lerp(0.0, 1.0, -0.5, real(vi), real(gridSize)-0.5)]) | vi in 0..(gridSize-1), ui in 0..(gridSize-1) };
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: -0.5, real(vi), real(gridSize)-0.5)]) | vi in 0..(gridSize-1), ui in 0..(gridSize-1) };