1 function Dense_pts = Fit_spline (Pts)
\r
6 % making splines separately for X and Y, but with common parameter
\r
9 for i=1:length(Xdata)-1
\r
10 Length = Length + norm(Pts(:, i+1) - Pts(:, i));
\r
11 Param(i+1) = Length;
\r
14 % sampling at a dense set of points
\r
15 Gridpts = [min(Param):0.1:max(Param)];
\r
16 Xspline = round(spline(Param, Xdata, Gridpts));
\r
17 Yspline = round(spline(Param, Ydata, Gridpts));
\r
19 % if not sufficiently dense, adjusting those
\r
20 k = 0; Dense_pts = zeros(2, 0);
\r
21 for i=1:length(Xspline)-1
\r
22 if max(abs(Xspline(i+1)-Xspline(i)), abs(Yspline(i+1)-Yspline(i))) > 1
\r
23 for j=0:abs(Xspline(i+1)-Xspline(i))
\r
25 Dense_pts(:, k) = [Xspline(i) + j*sign(Xspline(i+1)-Xspline(i)); ...
\r
28 for j=0:abs(Yspline(i+1)-Yspline(i))
\r
30 Dense_pts(:, k) = [Xspline(i+1); ...
\r
31 Yspline(i) + j*sign(Yspline(i+1)-Yspline(i))];
\r
35 Dense_pts(:, k) = [Xspline(i); Yspline(i)];
\r