-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo5.m
51 lines (35 loc) · 995 Bytes
/
demo5.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
% DEMO5
%
% Description
% "Fit" a contour, using motion normal to an interface. Start with an
% initial "checker-board" level-set function.
% Print out help message.
help demo5
dims = [80 80];
%
% Form the contour that we will attempt to mimic.
%
lset_grid(dims);
phi0 = lset_box([0 0], [30 10]);
phi0 = lset_union(phi0, lset_box([0 0], [10 30]));
[phi0, err] = signed_distance(phi0, 1e-1);
%
% Initialize grid.
%
lset_grid(dims);
%
% Construct the initial structure/interface.
%
phi = lset_checkered;
[phi, err] = signed_distance(phi, 1e-1);
%
% Move the surface within the velocity field, keep phi "close" to a
% signed distance function.
%
for cnt = 1 : 50
lset_plot(phi); % Visualize.
hold on; contour(phi0', [0 0], 'g-', 'LineWidth', 2); hold off;
drawnow
phi = update_interface(phi, [], phi0, 0); % Move the interface.
[phi, err] = signed_distance(phi, 1e-1); % Make phi more sdf-like.
end