% A parametric cubic spline for a generic figure
% in 2D for illustration purposes.
% cubicSplineParametricDiagram.m
% K. Ming Leung, 03/08/03

x=[-1 -1.02 -1 -0.875 -0.5 -0.25 0 0.5 0.75 1 0.75 0.52 0.25 0 -0.23 -0.26 -0.2 0 0.25 0.5 0.75 1]';
y=[ 0 0.25 0.5 0.75 0.97 1.01 1 0.87 0.75 0.5 0.3 0.24 0.13 0 -0.25 -0.4 -0.5 -0.63 -0.75 -0.84 -0.915 -1]';
t=linspace(0,1,length(x)); nPtsPlot=10;

[tPlot1, xPlot] = cubicSplineNaturalF(t,x,nPtsPlot);
[tPlot2, yPlot] = cubicSplineNaturalF(t,y,nPtsPlot);
plot(xPlot,yPlot,'lineWidth',2);
axis equal; axis([-1.2 1.2 -1.2 1.2]); hold on;
plot(x,y,'r.','markerSize',14);
ylabel('y','FontSize',18);
xlabel('x','FontSize',18);
title('Parametric Cubic Spline of a Curve','FontSize',24);