-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo4.m
62 lines (43 loc) · 1.19 KB
/
demo4.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
53
54
55
56
57
58
59
60
% DEMO4
%
% Description
% "Fit" a contour, using motion normal to an interface.
% Print out help message.
help demo4
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.
%
% Simple circle.
phi = lset_circle([-5 0], 15);
%
% Construct the signed distance function for the interface.
%
[phi, err] = signed_distance(phi, 1e-3);
%
% Move the surface within the velocity field, keep phi "close" to a
% signed distance function.
%
while (true)
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.
% % Use this update to add a significant amount of curvature motion,
% % this keeps the contour smooth.
% phi = update_interface(phi, [], phi0, 10); % Move the interface.
[phi, err] = signed_distance(phi, 1e-1); % Make phi more sdf-like.
end