function value = dist2c ( e )

%*****************************************************************************80
%
%% dist2c() returns the distance to collision.
%
%  Discussion:
%
%    Assuming the particle has a given energy, and assuming it is currently
%    somewhere inside the shield, it is possible to determine a typical distance
%    which the particle can travel before it collides with the material of
%    the shield.
%
%    The computation of the collision distance is made by estimating a
%    "cross section" (as though having more energy made the particle "bigger"
%    and hence more likely to collide) and then randomly selecting a distance
%    that is logarithmically distributed.
%
%  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 energy of the particle.
%
%  Output:
%
%    real VALUE, the distance the particle can travel
%    through the slab before colliding.
%
  u = rand ( 1, 1 );

  value = - log ( u ) / cross_section ( e );

  return
end

