Calculate a level-set function for the set difference phi1 minus phi2.
See also: ls_complement, ls_union, ls_intersect, ls_setxor, setdiff.
The following code
n = 100;
x = linspace (-7, 7, n);
[XX, YY] = meshgrid (x, x);
phi1 = (XX - 2).^2 + YY.^2 - 3^2;
phi2 = (XX + 2).^2 + YY.^2 - 3^2;
phi = ls_setdiff (phi1, phi2);
figure ();
subplot (1, 2, 1);
hold ("on");
contour (XX, YY, phi1, [0, 0], "k");
contour (XX, YY, phi2, [0, 0], "k");
hold ("off");
axis ("equal");
subplot (1, 2, 2);
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 |
|---|
![]() |
The following code
n = 100;
x = linspace (-7, 7, n);
[XX, YY] = meshgrid (x, x);
phi1 = XX.^2 + YY.^2 - 6^2;
phi2 = XX.^2 + YY.^2 - 3^2;
phi = ls_setdiff (phi1, phi2);
figure ();
subplot (1, 2, 1);
hold ("on");
contour (XX, YY, phi1, [0, 0], "k");
contour (XX, YY, phi2, [0, 0], "k");
hold ("off");
axis ("equal");
subplot (1, 2, 2);
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