Navigation

Operators and Keywords

Function List:

C++ API

Function File: phi = ls_genbasic (XX, YY, shape, ...)
Function File: phi = ls_genbasic (XX, ..., shape, ...)
Function File: phi = ls_genbasic (..., "sphere", c, r)
Function File: phi = ls_genbasic (..., "box", a, b)
Function File: phi = ls_genbasic (..., "half", p, n)

Construct the level-set function for a basic geometric shape. The arguments XX and YY should be the coordinates where the level-set function should be evaluated. For a case that is not 2D, the respective number of arguments must be given.

shape specifies what shape should be constructed, the arguments following are shape-dependent. Possible shapes:

"sphere"

Construct a sphere or ellipsoid with centre c and radius r. Optionally, r can also be a vector giving the radii in each coordinate direction separately.

"box"

Construct a box spanned by the given two vertex coordinates.

"half"

Construct a half-space at one side of a hyperplane. The plane is specified by some point p on it, and the normal vector n pointing into the domain.

See also: ls_union, ls_intersect, ls_setdiff, meshgrid, ndgrid.

Demonstration 1

The following code

  n = 200;
  x = linspace (-7, 7, n);
  [XX, YY] = meshgrid (x, x);

  phi1 = ls_genbasic (XX, YY, "box", [-5, -3], [3, 6]);
  phi2 = ls_genbasic (XX, YY, "sphere", [-1; 1], 2);
  phi3 = ls_genbasic (XX, YY, "sphere", [0; 0], [6, 1]);
  phi4 = ls_genbasic (XX, YY, "half", [3, -3], [1, -2]) / 8;

  phi = ls_union (ls_setdiff (phi1, phi2), phi3, phi4);
  figure ();
  hold ("on");
  imagesc (x, x, phi);
  set (gca (), "ydir", "normal");
  ls_sign_colourmap ();
  contour (XX, YY, phi, [0, 0], "k");
  hold ("off");
  axis ("equal");

Produces the following figure

Figure 1

Package: level-set