forked from fastalgorithms/rounding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
polygon_test.m
47 lines (40 loc) · 1.02 KB
/
polygon_test.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
%
% (c) 2016 Charles L. Epstein and Michael O'Neil
%
%
% See the corresponding paper for technical information:
%
% C. L. Epstein and M. O'Neil, "Smoothed corners and scattered
% waves", arXiv:1506.08449, 2016.
%
% This script calls the routines used for smoothing polygons in two
% dimensions. n-gon polygons are simply generated as a list of
% vertices and edges, and then smoothed by convolving with a
% compactly support kernel.
%
addpath('./src');
% specify the number of edges
n0 = 3;
% compute the vertices
ax= [cos(2*pi*(0:(n0-1))/n0),sin(2*pi*(0:n0-1)/n0)];
vx = reshape(ax, [n0 2]);
% set the base rounding size
dh = .05;
n1 = 4;
figure, hold on
for j = 1:n1
[psa,nt] = smthpoly(vx, j*dh, 4, 2048);
plot(psa(1:nt,1), psa(1:nt,2), '-', 'LineWidth', 2)
end
% plot the original polygon
nv = sz(vx);
for j =1:nv
j2 = 1+mod(j,nv);
X=[vx(j,1),vx(j2,1)];
Y=[vx(j,2),vx(j2,2)];
line(X, Y, 'Color', [1,0,0], 'LineWidth', 1);
end
axis equal
hold off