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

# SCM Repository

[diderot] View of /branches/charisee/ertest/vispaper/gmiso2d/gmiso2d.diderot
 [diderot] / branches / charisee / ertest / vispaper / gmiso2d / gmiso2d.diderot

# View of /branches/charisee/ertest/vispaper/gmiso2d/gmiso2d.diderot

Wed Feb 25 21:47:43 2015 UTC (4 years, 7 months ago) by cchiw
File size: 1371 byte(s)
`added sqrt,pow, and examples`
```/*
\$DDRO_HOME/branches/vis12/bin/diderotc --exec gmiso2d.diderot \
&& ./gmiso2d \
&& unu jhisto -i x.nrrd -b 800 800 -min 0 0 -max 1 1 \
| unu 2op neq - 0 \
| unu quantize -b 8 -o gmiso2d.png
*/
//note my branch doesn't know Inputs, "InputWithDefault"
//input real isoval = 0.5;

real isoval = 0.5;
field#2(2)[] V = bspln3 ⊛ load("../../../data/ddro.nrrd");
field#1(2)[] F = ∇V•∇V - isoval;
field#0(2)[2] gradF = ∇F;

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 (m == 0.0)
die;

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

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

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

/*
different in 3D:
vec2 -> vec3
field#1(2)[] F -> field#1(3)[] F
initially over 3D grid
*/
```

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