if pick == -1,

% Test -1
NumTerms = [2];
Sterms = [[1 2 ]; ...
          [1 2 ]; ...
          [1 2 ]; ...
          [1 2 ]];
tC = [1 1 1];
Curve = [ 0 1 1 1 2 1 ];

elseif pick == 0

%
% Test 0
NumTerms = [2];
Sterms = [ [ 1 0 ] ; ...
           [ 1 1 ] ; ...
           [ 1 0 ] ; ...
           [ 2 -6] ];
tC = [1 1 1];
Curve = [ 1 1 1 2 1 3 ];

elseif pick == 1

%
% Problem 4.6.1
NumTerms = [[ 3 0 ];[ 0 4 ]];
Sterms = [ [ 1 0 0 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 10 ]' ];
tC = [2 2 2];
Curve = [ 0 0 1 1 0 1 2 0 1 ];

% Plot Curve and Surface
t = (-1:.1:1);
Cx = polyval( fliplr(Curve( 1 : tC(1)+1 )) , t );
Cy = polyval( fliplr(Curve( tC(1)+2 : tC(1)+tC(2)+2 )) , t );
Cz = polyval( fliplr(Curve( tC(1)+tC(2)+3 : tC(1)+tC(2)+tC(3)+3 )) , t );
density = 10;
Cxrange = ( min(Cx)-1 : (max(Cx)-min(Cx))/density : max(Cx)+1 );
Cyrange = ( min(Cy)-1 : (max(Cy)-min(Cy))/density : max(Cy)+1 );
[ Cxmat, Cymat ] = meshgrid( Cxrange, Cyrange );
Surface11 = -Cxmat - Cymat;
Surface22 = (3/7)*Cxmat + (5/7)*Cymat + (10/7);
figure(1)
hold off, clg
mesh( Cxrange , Cyrange , Surface11 );
hold on
mesh( Cxrange , Cyrange , Surface22 );
plot3(Cx,Cy,Cz,'w')
xlabel('X'); ylabel('Y'); zlabel('Z')
grid
pause
view([1 -1 -.075])

elseif pick == 2

%
% Problem 4.6.2
NumTerms = [[ 3 0 ];[ 0 4 ]];
Sterms = [ [ 1 0 0 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 10 ]' ];
tC = [3 3 3];
Curve = [ 0 0 0 1 1 0 0 1 2 0 0 1 ];

% Plot Curve and Surface
t = (-2:.1:2);
Cx = polyval( fliplr(Curve( 1 : tC(1)+1 )) , t );
Cy = polyval( fliplr(Curve( tC(1)+2 : tC(1)+tC(2)+2 )) , t );
Cz = polyval( fliplr(Curve( tC(1)+tC(2)+3 : tC(1)+tC(2)+tC(3)+3 )) , t );
density = 20;
Cxrange = ( min(Cx)-1 : (max(Cx)-min(Cx))/density : max(Cx)+1 );
Cyrange = ( min(Cy)-1 : (max(Cy)-min(Cy))/density : max(Cy)+1 );
[ Cxmat, Cymat ] = meshgrid( Cxrange, Cyrange );
Surface11 = -Cxmat - Cymat;
Surface22 = (3/7)*Cxmat + (5/7)*Cymat + (10/7);
figure(1)
hold off, clg
mesh( Cxrange , Cyrange , Surface11 );
hold on
mesh( Cxrange , Cyrange , Surface22 );
plot3(Cx,Cy,Cz,'w')
xlabel('X'); ylabel('Y'); zlabel('Z')
grid
pause
view([1 -1 -.075])

elseif pick == 3

%
% Problem 4.6.3
NumTerms = [[ 3 0 ];[ 0 4 ]];
Sterms = [ [ 1 0 0 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 10 ]' ];
tC = [1 1 1];
Curve = [ 0 1 1 1 2 1 ];

% Plot Curve and Surface
t = (-4:.1:4);
Cx = polyval( fliplr(Curve( 1 : tC(1)+1 )) , t );
Cy = polyval( fliplr(Curve( tC(1)+2 : tC(1)+tC(2)+2 )) , t );
Cz = polyval( fliplr(Curve( tC(1)+tC(2)+3 : tC(1)+tC(2)+tC(3)+3 )) , t );
density = 20;
Cxrange = ( min(Cx)-1 : (max(Cx)-min(Cx))/density : max(Cx)+1 );
Cyrange = ( min(Cy)-1 : (max(Cy)-min(Cy))/density : max(Cy)+1 );
[ Cxmat, Cymat ] = meshgrid( Cxrange, Cyrange );
Surface11 = -Cxmat - Cymat;
Surface22 = (3/7)*Cxmat + (5/7)*Cymat + (10/7);
figure(1)
hold off, clg
mesh( Cxrange , Cyrange , Surface11 );
hold on
mesh( Cxrange , Cyrange , Surface22 );
plot3(Cx,Cy,Cz,'w')
xlabel('X'); ylabel('Y'); zlabel('Z')
grid
pause
view([1 -1 -.3])

elseif pick == 4

%
% Problem 4.6.4
NumTerms = [[ 1 0 ];[ 0 4 ]];
Sterms = [ [ 0 0 0 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 9 ]' ];
tC = [2 2 2];
Curve = [ 0 0 1 1 0 1 2 0 1 ];

elseif pick == 5

%
% Problem 4.6.5
NumTerms = [[ 3 0 ];[ 0 4 ]];
Sterms = [ [ 1 0 0 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 8 ]' ];
tC = [2 2 2];
Curve = [ 0 0 1 1 0 1 2 0 1 ];

elseif pick == 6

%
% Problem 4.6.6
NumTerms = [[ 3 1 ];[ 1 4 ]];
Sterms = [ [ 1 0 0 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 1 0 0 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 10 ]' ];
tC = [2 2 2];
Curve = [ 0 0 1 1 0 1 2 0 1 ];

elseif pick == 7

%
% Problem 4.6.7
NumTerms = [[ 2 2 7 ];[ 2 3 4 ];[ 1 4 3 ]];
Sterms = [ [ 1 1 0 1 ]' , ...
           [ 0 0 5 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 5 -7 ]' , ...
           [ 0 0 0 2 ]' , ...
           [ 0 0 0 3 ]' , ...
           [ 0 2 0 -1 ]' , ...
           [ 0 0 0 1 ]' , ...
           [ 2 0 0 -1 ]' , ...
           [ 1 1 2 1 ]' , ...
           [ 1 0 0 3 ]' , ...
           [ 0 1 0 5 ]' , ...
           [ 0 0 1 -7 ]' , ...
           [ 0 0 0 8 ]' , ...
           [ 0 0 0 5 ]' , ...
           [ 1 0 0 1 ]' , ...
           [ 0 1 0 1 ]' , ...
           [ 0 0 1 1 ]' , ...
           [ 1 1 0 1 ]' , ...
           [ 1 0 1 1 ]' , ...
           [ 0 1 1 1 ]' , ...
           [ 0 0 0 3 ]' , ...
           [ 1 0 0 1 ]' , ...
           [ 0 0 1 3 ]' , ...
           [ 0 1 1 -9 ]' , ...
           [ 3 0 0 1 ]' , ...
           [ 0 4 0 -1 ]' , ...
           [ 0 0 5 4 ]' ];
tC = [5 5 5];
Curve = [ 7 -3 0 0 0 1 ...
          1  0 1 0 0 1 ...
          2  0 1 0 0 1 ];

end
