function otime = sdrplot(th,tt,h1,t1,h2,t2,n,tsp,ssp,org)

% time = sdrplot(th,tt,h1,t1,h2,t2,n,tsp,ssp,org)
% B. A. Moran, 03/28/96

%    Copyright (C) 1995-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: sdrplot.m,v 1.1 2000/01/10 19:08:33 rob Exp $

if nargin < 10                          % default origin
    org = [0 0];
end

if nargin < 9                           % default speeds
    tsp = 1.3;
    ssp = 1.3;
end

pos = zeros( 4*n+1, 2 );
time = zeros( 4*n + 1, 1 );
pos( 1, : ) = org;
hr = pi/180*th;
pos( 2, : ) = pos( 1, : ) + tsp*tt*[ cos(hr) sin(hr) ];

time(2) = tt;
mode = 1;
for i = 3:(4*n+1)
    if mode == 1
        hr = pi/180*h1;
        ll = ssp*t1;
        time(i) = time(i-1) + t1;
        mode = 2;
    elseif mode == 2
        hr = pi/180*h2;
        ll = ssp*t2;
        time(i) = time(i-1) + t2;
        mode = 3;
    elseif mode == 3;
        hr = pi/180*(h1 + 180);
        ll = ssp*t1;
        time(i) = time(i-1) + t1;
        mode = 4;
    else
        hr = pi/180*h2;
        ll = ssp*t2;
        time(i) = time(i-1) + t2;
        mode = 1;
    end
    pos( i, : ) = pos( i-1, : ) + ll*[ cos(hr) sin(hr) ];
end

plot( pos(:,2), pos(:,1), 'c', pos(1,2), pos(1,1), 'go',...
      pos(4*n+1,2), pos(4*n+1,1), 'rx' );
for i = 1:length(time)
    text( pos(i,2), pos(i,1), hh2hms(time(i)/3600), 'FontSize', 10 );
end

title( 'Projected Trajectory: survey_dead_reckon' );
xlabel( 'East (m)' )
ylabel( 'North (m)' )
set( gca, 'Aspect', [nan 1] );
zoom on

disp( ['survey time:  ' hh2hms(max(time)/3600)] );

if nargout > 0, otime = time; end
