sphrand

Get random orientations in 3D from a uniform orientation distribution.

Syntax
vecs = sphrand(N)
vecs = sphrand(N,nOctants)
[phi,theta] = sphrand(...)
[x,y,z] = sphrand(...)
Description

sphrand does in a random way what sphgrid does more systematically. It calculates N points on the unit sphere. In the limit of [eqn] these points are evenly distributed, since the underlying distribution is a uniform one.

If nOctants is specified, it determines the number of octants over which to generate the points. It can be 1 (one octant), 2 (two octants, part of upper hemisphere with y>0), 4 (upper hemisphere) or 8 (whole sphere).

The result containing the set of points on the sphere can be in one of three forms:

Examples

The command

[phi,theta] = sphrand(10000,8);

generates 10000 points randomly distributed over the whole sphere. The plot

plot(phi*180/pi,theta*180/pi,'.');
set(gca,'YDir','reverse'); axis tight
xlabel('phi'); ylabel('theta');

shows that in a theta vs. phi projection there is reduced point density around the north and south poles.

See also

ang2vec, vec2ang, sphgrid