function [East,Nrth] = drplot( time, yaw, pitch, speed, arg5, arg6 )
%DRPLOT      Plots vehicle trajectory by dead reckoning.
%   [east,north] = DRPLOT( TIME, YAW, PITCH, SPEED, ORIGIN, POS )
%   integrates the horizontal component of the vehicle velocity and
%   displays a vehicle trajectory in a square plot.  ORIGIN is an
%   optional pair [E N] that specify initial position.  East and North
%   vectors are made available if desired.  POS is an optional
%   argument specifying the position of the window on the screen.
%
%   See also DRCALC, WINPOS.

%----------------------------------------------------------------------
%			  Copyright (C) 1995
%		Massachussetts Institute of Technology
%	       Sea Grant Underwater Vehicles Laboratory
%----------------------------------------------------------------------
%     $Revision: 1.3 $			$State: Exp $
%     $Author: bamoran $		$Date: 1998/07/01 13:39:05 $
%----------------------------------------------------------------------

global run_name;

error( nargchk(4, 6, nargin) );	% mathworks function

if nargin == 6			% drplot(t,y,p,s,org,pos)
    winpos( arg6 );
    origin = arg5;
elseif nargin == 5		% drplot(...,pos) or drplot(...,org)

    if length(arg5) == 4 | isstr(arg5)
        winpos( arg5 );
        origin = [0 0];
    else
        origin = arg5;
    end
end
				% do calculations
[east,nrth] = drcalc( time, yaw, pitch, speed, origin );

if isempty( get(gcf, 'name') )
    set( gcf, 'name', 'Dead Reckoning Plot' );
end

if isempty( get(gcf, 'children') )
    plot( origin(1), origin(2), 'go' );
    set( gca, 'aspectratio', [1 1] );
    title( ['Vehicle Track by Dead Reckoning: ' run_name] );
    xlabel( 'East (m)' );
    ylabel( 'North (m)' );
else
    line( origin(1), origin(2), 'color', [0 .5 0], 'linestyle', 'o' );
end
line( east, nrth, 'color', 'b' );
zoom on;

if nargout > 0
    East = east;
    if nargout > 1, Nrth = nrth; end
end	
return;
