clear all

dist = 5000;	% section horizontal distance (m)
maxZ = 50;	% maximum depth of section (m)
speed = 1.5;	% AUV speed m/s

pitches = [30 20 10]; npitch=length(pitches);  % vehicle pitch

figure(1); clf; giffig_wide

for P=1:npitch;
 clear locZ locX 

 disp([' ']);
 pitch = pitches(P)*pi/180;
 disp(['Pitch : ' num2str(pitches(P)) ' degrees']);

 % single yoyo distance along surface
 dx = 2 * (maxZ/tan(pitch));
 disp(['Surface distance along single yoyo cycle : ' num2str(dx) ' m']);

 % single yoyo distance along path 
 dp = 2 * (maxZ/sin(pitch));
 disp(['Path distance along single yoyo cycle : ' num2str(dp) ' m']);

 % number of yoyo's that will fit in distance
 ny = dist/dx;
 disp(['Number of yoyo cycles in ' int2str(dist) ' m of sampling : ' num2str(ny) ]);

 % time required to complete 
 auvdist = ny*dp;
 disp(['Path distance along all yoyo cycles : ' num2str(auvdist) ' m']);
 time = (auvdist/speed)/3600;	 % hours
 time=time*60;
 disp(['Hours required to complete : ' num2str(time) ]);

 for N = 1:ceil(ny);
  locZ(:,N) = [1 maxZ 1]'; 
  locX(:,N) = [0 dx/2 dx/2]';
 end 
 locZ=locZ(:); locX=cumsum(locX(:));
 
 eval(['subplot(' int2str(npitch) ',1,' int2str(P) ')']);
 plot(locX/1000,locZ,'k'); 
 axis([0 dist/1000 0 maxZ+1]); 
 set(gca,'ydir','reverse');
 set(gca,'fontweight','bold','fontsize',12);
 if P==npitch; xlabel('distance (km)'); end
 ylabel('depth (m)');
 % title(['Pitch = ' num2str(pitches(P)) setstr(176) ', Horizontal resolution : ' num2str(dx) ' m, Time to complete : ' num2str(time) ' minutes']);
 title(['Pitch = ' num2str(pitches(P)) setstr(176) ', Horizontal resolution : ' num2str(round(dx)) ' m, Time to complete : ' num2str(round(time)) ' minutes']);

 frame; t=text(.5,.97,['At AUV speed of ' num2str(speed) ' m/s : ']);

 set(t,'horizontalalignment','center','fontsize',12,'fontweight','bold');
end
