Calculate a level-set function for the set “xor” of the two domains given via phi1 and phi2. In other words, returned is a domain that contains all points that are in precisely one of the sets but not in both.
See also: ls_complement, ls_union, ls_intersect, ls_setdiff, setxor.
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_setxor (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