function circle_map_dots ( a, norm_type )

%*****************************************************************************80
%
%% CIRCLE_MAP_DOTS plots the image of the unit circle under the 2x2 matrix A.
%
%  Discussion:
%
%    A typical 2x2 matrix will map the unit circle to some kind of tilted 
%    ellipse.  The aspect ratio of the ellipse (ratio of major to minor axes) 
%    is a measure of the conditioning of the matrix.
%
%    A singular matrix maps the unit circle to a line.
%
%    A diagonal matrix maps the unit circle to an ellipse with no tilting.
%    (There is no rotation.)
%
%    An orthogonal matrix maps the unit circle to the unit circle (but points
%    may have rotated.)
%
%    The identity matrix maps the unit circle to itself.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 January 2019
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real A(2,2), the matrix whose mapping of the unit circle 
%    is to be studied.
%
%    Input, real/string NORM_TYPE:
%    1, l1 norm is used to define unit circle.
%    2, l2 norm is used to define unit circle.
%    'Inf', l-infinity norm is used to define unit circle.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'CIRCLE_MAP_DOTS\n' );
  fprintf ( 1, '  Given a matrix A,\n' );
  fprintf ( 1, '  plot points x on the unit circle, and\n' );
  fprintf ( 1, '  the images A*x of those points.\n' );

  if ( nargin < 1 )
    a = [ 4.0, 1.0; ...
          1.0, 2.0 ];
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Matrix A not supplied, using default.\n' );
  end

  if ( nargin < 2 )
    norm_type = 2;
    fprintf ( 1, '\n' );
    fprintf ( 1, '  norm_type not supplied, using default norm_type = 2.\n' );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Matrix A:\n' );
  fprintf ( 1, '\n' );
  disp ( a );
%
%  Estimate appropriate size of plot.
%
  n = 20;
  i = [ 0 : n - 1 ];
  angle = 2 * pi * i / n;
  r = 1.0;
  x = [ r*cos(angle); r*sin(angle) ];
  ax =  a * x;
  p_min = min ( min ( min ( ax ) ), min ( min ( x ) ) );
  p_max = max ( max ( max ( ax ) ), max ( max ( x ) ) );
%
%  Ready to start drawing random points.
%
  figure ( 1 )
  clf
  hold on
  area = [];
  scatter ( [ p_min, p_max, p_max, p_min ], [ p_min, p_min, p_max, p_max ], area, 'k' );
  xlabel ( '--X axis--' )
  ylabel ( '--Y axis--' )
  axis ( [ p_min, p_max, p_min, p_max ] );
  axis equal
  axis tight
  axis square
  grid ( 'on' )
%
%  Plot points X and A*X.
%
  for n = 1 : 75

    x = 2 * rand ( 2, 1 ) - 1;
    x = x / norm ( x, norm_type );
    plot ( x(1), x(2), 'b.', 'Markersize', 25 );

    ax = a * x;
    plot ( ax(1), ax(2), 'r.', 'Markersize', 25 );

    plot ( [x(1), ax(1)], [x(2), ax(2)], 'm', 'Linewidth', 3 );

    pause ( 1 )

    plot ( [x(1), ax(1)], [x(2), ax(2)], 'w', 'Linewidth', 2 );

  end

  hold off
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'CIRCLE_MAP_DOTS:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
