% ----------------------- Test_Param2dSpline.m --------------------- % % Test the main routine Param2dSPline to see if it is implemented correctly % You should run this to see if your implementation agrees with the % published answers. For each Test Case you should turn in the % graph for smallest and largest values of n = #points on curve % (i.e. 2 graphs per Test Case) % table of errors for all values of n for each Test Case % (i.e. table with 3 columns labeled #points, #corners, error) % produced by this program % % Test Case 1: Quintic (no corner detection) % Test Case 2: Circle (no corner detection, closed curve) % Test Case 3: Cusp (with corner detection) % Test Case 4: Rose (no corner detection, closed curve) % Test Case 5: Jagged line (with corner detection) % Test Case 6: Jagged line (no corner detection) % Quintic disp(' ') disp(' '), disp('Case 1: Begin testing Quintic'), i = 0; nn=[]; errorbound=[]; cntnewcn=[]; for n=10:20:90; i = i+1; x = 4*((0:n-1)/(n-1)-.5); % y = (x-(-2)).*(x-(-1.8)).*(x-(-1)).*(x-.5).*(x-1.9); y = -quintic2(x,0*x); figure(i) [nn(i),xout,yout,s,xc,yc,newcn,errorbound(i)] = Param2dSpline( ... 0,x,y,'quintic2',0,[],0); cntnewcn(i) = length(newcn); disp(['Quintic, with ',int2str(n),' points; pause, hit return to continue']), pause end disp(' ') disp(' ') disp('Results for Quintic') disp(' #points # corners error ') format short e [nn',cntnewcn',errorbound'] disp('pause, hit return to continue'), pause % Circle disp(' ') disp(' ') disp('Case 2: Begin testing Circle') pi = atan(1)*4; i=0; nn=[]; errorbound=[]; cntnewcn=[]; for n = 10:20:90, i = i+1; theta = (0:n-1)*2*pi/n; x = .5*sin(theta); y = .5*cos(theta); figure(i) [nn(i),xout,yout,s,xc,yc,newcn,errorbound(i)] = Param2dSpline( ... 0,x,y,'circle2',1,[],0); cntnewcn(i) = length(newcn); disp(['Circle, with ',int2str(n),' points; pause, hit return to continue']), pause end disp(' ') disp(' ') disp('Results for Circle') disp(' #points # corners error ') format short e [nn',cntnewcn',errorbound'] disp('pause, hit return to continue'), pause % Cusp disp(' ') disp(' ') disp('Case 3: Begin testing Cusp') pi = atan(1)*4; i=0; nn=[]; errorbound=[]; cntnewcn=[]; for n = 11:20:91, i = i+1; theta = (0:n-1)*2*pi/n; y = 2*((0:n-1)/(n-1)-.5); x = (y.^2).^(1/3); figure(i) [nn(i),xout,yout,s,xc,yc,newcn,errorbound(i)] = Param2dSpline( ... 0,x,y,'cusp2',0,[],1); cntnewcn(i) = length(newcn); disp(['Cusp, with ',int2str(n),' points; pause, hit return to continue']), pause end disp(' ') disp(' ') disp('Results for Cusp') format short e disp(' #points # corners error ') format short e [nn',cntnewcn',errorbound'] disp('pause, hit return to continue'), pause % Rose disp(' ') disp(' ') disp('Case 4: Begin testing Rose') pi = atan(1)*4; i=0; nn=[]; errorbound=[]; cntnewcn=[]; for n = [6:10,15,20:20:100] i = i+1; theta = (0:n-1)*pi/n; x = .5*sin(5*theta).*cos(theta); y = .5*sin(5*theta).*sin(theta); figure(i) [nn(i),xout,yout,s,xc,yc,newcn,errorbound(i)] = Param2dSpline( ... 0,x,y,'rose2',1,[],0); cntnewcn(i) = length(newcn); disp(['Rose, with ',int2str(n),' points; pause, hit return to continue']), pause end disp(' ') disp(' ') disp('Results for Rose') disp(' #points # corners error ') format short e [nn',cntnewcn',errorbound'] disp('pause, hit return to continue'), pause % Jagged, with corner detection disp(' ') disp(' ') disp('Case 5: Begin testing Jagged with corner detection') i=0; nn=[]; errorbound=[]; cntnewcn=[]; for n = [11:10:91] i = i+1; x = 2*((0:n-1)/(n-1)-.5); y = jagged2(x,0*x); figure(i) [nn(i),xout,yout,s,xc,yc,newcn,errorbound(i)] = Param2dSpline( ... 0,x,y,'jagged2',0,[],.1); cntnewcn(i) = length(newcn); disp(['Jagged, with ',int2str(n),' points; pause, hit return to continue']), pause end disp(' ') disp(' ') disp('Results for Jagged with corner detection') disp(' #points # corners error ') format short e [nn',cntnewcn',errorbound'] disp('pause, hit return to continue'), pause % Jagged, without corner detection disp(' ') disp(' ') disp('Case 6: Begin testing Jagged without corner detection') i=0; nn=[]; errorbound=[]; cntnewcn=[]; for n = [11:10:91] i = i+1; x = 2*((0:n-1)/(n-1)-.5); y = jagged2(x,0*x); figure(i) [nn(i),xout,yout,s,xc,yc,newcn,errorbound(i)] = Param2dSpline( ... 0,x,y,'jagged2',0,[],0); cntnewcn(i) = length(newcn); disp(['Jagged, with ',int2str(n),' points; pause, hit return to continue']), pause end disp(' ') disp(' ') disp('Results for Jagged without corner detection') disp(' #points # corners error ') format short e [nn',cntnewcn',errorbound']