next up previous contents
Next: 5.3.5 Direction Vector Sampling Up: 5.3 Generation of Random Previous: 5.3.3 Direction Vector Calculation

5.3.4 Cosine Distribution

The most frequently used distribution is the cosine distribution, which is required to describe the arrival angles of neutral particles (2.5) or diffusive reemission (2.18). The cosine distribution can be seen as a special case of the power cosine distribution (2.6) with $ {\nu}=1$ or as a special case of the coned cosine distribution with $ {\theta}_{\text{cone}}=\frac{\pi}{2}$ . As shown in the next section, sampling a cosine distribution using Algorithm 5.2 is faster than using Algorithm 5.3 for the coned cosine distribution. Therefore, the power cosine distribution with $ {\nu}=1$ is the common technique for sampling a cosine distribution [37]. However, the polar angle is usually not of interest. It is just an intermediate result passed to Algorithm 5.4 to generate a unit vector as needed for ray tracing.

In the following discussion an alternative method is proposed, which samples a unit vector obeying the cosine distribution directly, without the need of an additional rotation as described in Section 5.3.3. The method uses the fact that the sum of the given direction vector $ {\vec{v}}$ and a unit random vector $ {\vec{\omega}}'$ , which is uniformly distributed over a sphere, follows a cosine distribution. As illustrated in Figure 5.6, the area $ {d}{A}$ seen from the origin $ {O}$ in a direction with polar angle $ {\theta}$ within an infinitesimal solid angle $ {d}{\Omega}$ is

$\displaystyle {d}{A}=4\cos{\theta}\,{d}{\Omega}.$ (5.52)

As a consequence, the desired random vector $ {\vec{\omega}}$ can be obtained from a spherically distributed unit vector $ {\vec{\omega}}'$ by

$\displaystyle {\vec{\omega}}=\frac{{\vec{v}}+{\vec{\omega}}'}{\lVert{\vec{v}}+{\vec{\omega}}'\rVert}.$ (5.53)

For the spherical distribution numerous methods have been proposed in the past. So far the most efficient way to pick a point on the unit sphere is described in [61,75,107] and is listed in Algorithm 5.5. Standard numeric libraries such as the GNU scientific library already provide ready implementations for that algorithm [36]. Therefore, a very simple and short vector sampling algorithm for the cosine distribution is given by Algorithm 5.6.

Figure: 5.6 The sum of the given direction $ {\vec{v}}$ and a random unit vector $ {\vec{\omega}}'$ uniformly distributed over a sphere leads to a cosine distribution.
Image fig_5_6


\begin{algorithm}
% latex2html id marker 9606\caption{Picking a random point o...
...s $\lVert{\vec{\omega}}\rVert=1$
\EndFunction
\end{algorithmic}}
\end{algorithm}


\begin{algorithm}
% latex2html id marker 9618\caption{Generation of a $\cos{\t...
...$
\State\Return ${\vec{\omega}}$
\EndFunction
\end{algorithmic}}
\end{algorithm}


next up previous contents
Next: 5.3.5 Direction Vector Sampling Up: 5.3 Generation of Random Previous: 5.3.3 Direction Vector Calculation

Otmar Ertl: Numerical Methods for Topography Simulation