<reponame>berghaus/cernlib-docs<gh_stars>1-10
% 15 mai 1996
\Version {RN3DIM}                              \Routid{V131}
\Keywords{DISTRIBUTION THREE TWO DIMENSION 3-D 2-D NUMBER RANDOM VECTOR}
\Author{<NAME>}                              \Library{MATHLIB}
\Submitter{}                                   \Submitted{22.04.1996}
\Language{Fortran}                        %\Revised{}
\Cernhead {Random Two- and Three-Dimensional Vectors}
{\tt RN3DIM} generates random vectors, uniformly
distributed over the surface of a sphere of given radius. \\
{\tt RN2DIM} generates random vectors, uniformly
distributed over the circumference of a circle of given radius.
\Structure
{\tt SUBROUTINE} subprogram \\
User Entry Names: \Rdef{RN2DIM}, \Rdef {RN3DIM} \\
External References: \Rind{RANLUX}{V115}
\Usage
\begin{verbatim}
    CALL RN3DIM(X,Y,Z,XLONG)
\end{verbatim}
\begin{DLtt}{12345678}
\item[X,Y,Z] ({\tt REAL}) A random 3-dimensional vector of length
{\tt XLONG}.
\item[XLONG] ({\tt REAL}) Length of the vector (to be specified on
entry).
\end{DLtt}
\begin{verbatim}
    CALL RN2DIM(X,Y,XLONG)
\end{verbatim}
\begin{DLtt}{12345678}
\item[X,Y] ({\tt REAL}) A random 2-dimensional vector of length
{\tt XLONG}.
\item[XLONG] ({\tt REAL}) Length of the vector (to be specified on
entry).
\end{DLtt}
\Method
A random vector in the unit cube is generated using {\tt RANLUX} (V115)
and is rejected if it lies outside the unit sphere. In the case of
{\tt RN3DIM}, this rejection
technique uses on average about 6 random numbers per vector, where only
two are needed in principle. However, it is faster than the classical
two-number technique which requires a square root, a sine, and a cosine.
\\ $\bullet$
