```
// inputs:
// * `eval_sdb` is the signed distance bound represeting a shape
// * `N` is the grid resolution
function apply_grid_hopping(eval_sdb, N)
{
for (var i=0; i < N; ++i)
for (var j=0; j < N; ++j)
{
var k=0;
while (true)
{
// set the origin of the ray
var x=-1.0/2.0+1.0/(2.0*N)+i/N;
var y=-1.0/2.0+1.0/(2.0*N)+j/N;
var z=-1.0/2.0+1.0/(2.0*N)+k/N;
// use ray marching to determine how much to move along the ray
var t = trace_ray(
[x, y, z], // origin of the ray
[0.0, 0.0, 1.0], // direction of the ray
eval_sdb, // signed distance bound
1.05*(1.0/2.0 - z), // max distance to travel
Math.sqrt(6.0)/(2.0*N) // distance to surface we require
);
// set the new value of z and its associated cell, (i, j, k)
z = z + t;
k = Math.floor(N*(z + 1.0/2.0 - 1.0/(2.0*N)));
// are we outside the polygonization volume?
if (k>N-1 || z>1.05/2.0)
break;
// polygonize cell (i, j, k)
... // <- polygonizaiton code goes here, e.g., Marching cubes
// move further along the z direction
++k;
}
}
}
```

If the ray intersects the surface and we denote the closest intersection to $\mathbf{r}\_0$ with $\mathbf{r}^\*$,
then the above iteration converges to $\mathbf{r}^\*$.
This is because
1. $\left|f\_S(\mathbf{r}\_n)\right|\geq 0$;
2. on the ray between $\mathbf{r}\_0$ and $\mathbf{r}^\*$, $f\_S(\mathbf{r})=0$ only for $\mathbf{r}=\mathbf{r}^\*$;
3. the iteration will never "overshoot" $\mathbf{r}^\*$ because $f\_S$ is a signed distance bound.
See reference [1] for additional analysis.
## Theoretical analysis of computational complexity
We analyze the asymptotic number of steps required by the method from previous section to polygonize a shape defined through its signed distance bound.
For non-fractal shapes, there are at most $O(N^2)$ cells that contain polygons.
The challenge is to isolate these cells in a fast manner.
The trivial way is to check all $N^3$ cells.
This may be too slow for some applications when high resolution (large $N$) is required.
Our claim is that the algorithm from the previous section is faster than that:
its complexity is $O(N^2\log N)$.
We provide evidence for this in the following steps:
1. provide a proof for polygonizing planes;
2. provide a proof for polygonizing axis-aligned boxes;
3. argue that any non-fractal shape can be approximated as a union of boxes.
These steps are explained in the following three subsections.
#### Polygonizing planes
A plane is a flat, two-dimensional surface that extends infinitely far.
Of course, we are interested in polygonizing only the part that intersects with the polygonization volume.
The exact signed distance from a point $\mathbf{r}$ to a plane $P$ is given by the following equation (see