function [ mu, azm, e ] = scattering ( e )

%*****************************************************************************80
%
%% scattering() returns the new direction and energy of a particle that is scattered.
%
%  Discussion:
%
%    The scattering direction is chosen uniformly on the sphere.
%
%    The energy of the scattered particle is chosen uniformly in
%    [ 0.3*E, E ].
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 September 2012
%
%  Author:
%
%    Original FORTRAN77 version by Kahaner, Moler, Nash.
%    MATLAB version by John Burkardt.
%
%  Reference:
%
%    David Kahaner, Cleve Moler, Steven Nash,
%    Numerical Methods and Software,
%    Prentice Hall, 1989,
%    ISBN: 0-13-627258-4,
%    LC: TA345.K34.
%
%  Input:
%
%    real E: the particle energy before collision. 
%
%  Output:
%
%    real MU, the cosine of the angle between the
%    particle's direction and the X axis.
%
%    real AZM, the azimuthal angle of the particle's
%    direction.
%
%    real E, the particle energy after collision and scattering.
%
  mu = - 1.0 + 2.0 * rand ( 1, 1 );
  azm = 2.0 * pi * rand ( 1, 1 );
  u = rand ( 1, 1 );

  e = ( u * 0.7 + 0.3 ) * e;

  return
end
