%%% You must first download from the course web page:
%%%   nice3d.m   ppval1.m  ppval2.m

% sample track with a loop
% given points on curve are 
P0 = [-2;0;2]; P1=[0;0;0]; P2=[0;0;1]; P3=[0;0;0]; P4=[2;0;2];

s = [ 0, 1, 2, 3, 4];         % Points correspond to s=0,1,2,3,4
P = [P0,P1,P2,P3,P4];

global pp
pp = spline(s,P);             % find coefficients of spline (for all 3 components of U)

% use ppval(pp,s)  for U(s)
%     ppval1(pp,s) for U'(s)
%     ppval2(pp,s) for U''(s)

% e.g. ppval(pp,2) gives P2
%      ppval(pp,[2 2.5 3]) gives [ P2, intermediate point, P3 ]

U = ppval(pp, 0:.1:4);        % evaluate at 41 points
figure(1)
plot3(U(1,:),U(2,:),U(3,:))   % and plot
nice3d; 

%%% You can rotate the graph by dragging with the mouse %%%
