Navigation

Operators and Keywords

Function List:

C++ API

Function File: d = ls_distance_fcn (phi, h = 1)

Calculate the distance function of a set. The domain is described by its level-set function, whose values on a rectangular grid with spacing h are given in the array phi.

In contrast to ls_signed_distance, which calculates the signed distance function, d will be set to zero on interior points. This allows ls_distance_fcn to be faster, as only exterior points are processed.

It may be a good idea to use ls_normalise on the level-set function before using this method, to prevent almost-zero values from underflowing due to the performed calculations.

See also: fastmarching, ls_signed_distance, ls_normalise.

Demonstration 1

The following code

  n = 100;
  x = linspace (-10, 10, n);
  h = x(2) - x(1);
  [XX, YY] = meshgrid (x, x);

  phi = ls_genbasic (XX, YY, "sphere", [0, 0], [8, 5]);
  d = ls_distance_fcn (phi, h);

  figure ();
  mesh (XX, YY, d);
  view ([45, 45]);

Produces the following figure

Figure 1

Package: level-set