function cometm(lat,lon,p)

%COMETM  Two dimensional comet plot projected on a map axes
%
%  COMETM(lat,lon) projects a comet plot in two dimensions
%  (z = 0) on the current map axes.  A comet plot is an animated
%  graph in which a circle (the comet head) traces the data points on the
%  screen.  The comet body is a trailing segment that follows the head.
%  The tail is a solid line that traces the entire function.  The
%  lat and lon vectors must be in the same units as specified in
%  the map structure.
%
%  COMETM(lat,lon,p) uses the input p to specify a comet body size of
%  p*length(lat)
%
%  COMETM activates a Graphical User Interface for projecting comet plots.
%
%  See also  COMET3M, COMET, COMET3

%  Copyright 1996-1998 by Systems Planning and Analysis, Inc. and The MathWorks, Inc.
% $Revision: 1.6 $
%  Written by:  E. Byrns, E. Brown



if nargin == 0
    comet3m;   return
elseif nargin < 2
    error('Incorrect number of arguments')
elseif nargin == 2
    p = [];
end

%  Argument tests

if any([min(size(lat))    min(size(lon))   ] ~= 1) | ...
   any([ndims(lat) ndims(lon)] > 2)
        error('Data inputs must be vectors')
elseif ~isequal(size(lat),size(lon))
        error('Inconsistent dimensions on input data')
elseif length(p) > 1
        error('Tail Length input must be a scalar')
end

%  Test for a map axes and get the map structure

[mstruct,msg] = gcm;
if ~isempty(msg);  error(msg);  end

%  Project the line data

[x,y,z,savepts] = mfwdtran(mstruct,lat,lon,[],'line');

%  Display the comet plot

nextmap;
if isempty(p);     comet(x,y)
    else;          comet(x,y,p)
end