function [ x, y, z ] = update ( mu, azm, d, x, y, z )

%*****************************************************************************80
%
%% update() determines the position of the particle after it has traveled D units.
%
%  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 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 D, the distance the particle traveled.
%
%    real X, Y, Z.  On the previous
%    coordinates of the particle.  On the updated coordinates of the
%    particle.
%
%  Output:
%
%    real X, Y, Z.  On the previous
%    coordinates of the particle.  On the updated coordinates of the
%    particle.
%
  s = sqrt ( 1.0 - mu * mu );

  x = x + d * mu;
  y = y + d * s * cos ( azm );
  z = z + d * s * sin ( azm );

  return
end

