function [ angle1, angle2, angle3 ] = circle_triple_angles_2d ( r1, r2, r3 )

%*****************************************************************************80
%
%% circle_triple_angles_2d() returns the angles formed by three circles in 2D.
%
%  Discussion:
%
%    A circle triple is a set of three tangent circles.  We assume
%    that no circle is contained in another.
%
%    We consider the triangle formed by joining the centers of the circles.
%
%    We report the angles in that triangle.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    17 September 2020
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Kenneth Stephenson,
%    Circle Packing, The Theory of Discrete Analytic Functions,
%    Cambridge, 2005.
%
%  Input:
%
%    real R1, R2, R3, the radii of the circles.
%
%  Output:
%
%    real ANGLE1, ANGLE2, ANGLE3, the angles in the triangle.
%
  angle1 = acos ...
  ( ...
    ( ...
      ( r1 + r2 )^2 + ( r1 + r3 )^2 - ( r2 + r3 )^2 ...
    ) / ...
    ( ...
      2.0 * ( r1 + r2 ) * ( r1 + r3 ) ...
    ) ...
  );

  angle2 = acos ...
  ( ...
    ( ...
      ( r2 + r3 )^2 + ( r2 + r1 )^2 - ( r3 + r1 )^2 ...
    ) / ...
    ( ...
      2.0 * ( r2 + r3 ) * ( r2 + r1 ) ...
    ) ...
  );

  angle3 = acos ...
  ( ...
    ( ...
      ( r3 + r1 )^2 + ( r3 + r2 )^2 - ( r1 + r2 )^2 ...
    ) / ...
    ( ...
      2.0 * ( r3 + r1 ) * ( r3 + r2 ) ...
    ) ...
  );

  return
end
