-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo2.m
54 lines (40 loc) · 1.22 KB
/
demo2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
% DEMO2
%
% Description
% Demonstrate interface movement under mean curvature.
%
% The most curved surfaces shrink the fastest, while concave boundaries
% actually grow outward. The disappearance of interfaces is demonstrated
% as well.
% Print out help message.
help demo2
%
% Initialize grid.
%
lset_grid([80 80]);
%
% Construct the initial structure/interface.
%
phi = lset_circle([0 0], 30);
phi = lset_intersect(phi, lset_complement(lset_circle([0 0], 27)));
phi = lset_union(phi, lset_circle([-10 0], 10));
phi = lset_union(phi, lset_circle([15 0], 10));
phi = lset_intersect(phi, lset_complement(lset_box([30 0], [78 4])));
%
% Construct the signed distance function for the interface.
%
[phi, err] = signed_distance(phi, 1e-1);
%
% Move the surface by mean curvature, keep phi "roughly" a signed
% distance function.
%
while (true)
lset_plot(phi); drawnow; % Visualize.
phi = update_interface(phi, [], 0, 3); % Move the interface.
try
[phi, err] = signed_distance(phi, 1e-3); % Make phi more sdf-like.
catch
lset_plot(phi); % Visualize.
break; % If signed_distance failed, we have no more interfaces.
end
end