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

# SCM Repository

[diderot] View of /branches/charisee/ertest/vispaper/viso2d/vmiso2d.diderot
 [diderot] / branches / charisee / ertest / vispaper / viso2d / vmiso2d.diderot

# View of /branches/charisee/ertest/vispaper/viso2d/vmiso2d.diderot

Revision 3066 - (download) (annotate)
Sat Mar 14 16:34:25 2015 UTC (4 years, 6 months ago) by cchiw
File size: 1107 byte(s)
load->image, det(), S*T
/*

../../../bin/diderotc vmiso2d.diderot \
&& ./vmiso2d \
&& unu jhisto -i vmiso2d.txt -b 600 600 -min -1 -1 -max 1 1 | \
unu 2op neq - 0 | \
unu quantize -b 8 -o vmiso2d.png \
&& open vmiso2d.png

*/

real isoval = 0.2;
field#2(2)[2] V = bspln3 ⊛ image("vec3.nrrd");
field#1(2)[] F = |V| - isoval;

int grid = 150;
int stepsMax = 10;
real epsilon = 0.000001;

strand RootFind(real xi,real yi) {
output vec2 x = [xi,yi];
int steps = 0;

update {
// Stop if we're no longer inside or taken too many steps.
if (!inside(x, V) || steps > stepsMax)
die;

// subsequent expressions are undefined if |∇F| is zero
if (|∇F(x)| == 0.0)
die;

// the Newton-Raphson step
vec2 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;

// we've converged if the change is small enough
if (|delta| < epsilon)
stabilize;
x -= delta;
steps += 1;
}
}

initially { RootFind(lerp(-1.5, 1.5, -0.5, ui, grid-0.5),
lerp(-1.5, 1.5, -0.5, vi, grid-0.5))
| vi in 0..(grid-1), ui in 0..(grid-1) };

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