geomc 1.0
A c++ linear algebra template library
Public Member Functions | Public Attributes | List of all members
Sampler< T > Class Template Reference

A class for randomly sampling a variety of regions over RN space. More...

#include <geomc/random/RandomTools.h>

Public Member Functions

 Sampler ()
 
 Sampler (Random *rng)
 
template<index_t N>
Vec< T, N > unit ()
 
template<index_t N>
Vec< T, N > unit (T radius)
 
template<index_t N>
Vec< T, N > solidball ()
 
template<index_t N>
Vec< T, N > solidball (T radius)
 
template<index_t N>
Vec< T, N > shell (T minradius, T maxradius)
 
template<index_t N>
Vec< T, N > box ()
 
template<index_t N>
Vec< T, N > box (Vec< T, N > lo, Vec< T, N > hi)
 
template<index_t N>
Vec< T, N > box (const Rect< T, N > &box)
 
Vec< T, 3 > cap (T half_angle_radians)
 
Vec< T, 3 > cap (Vec< T, 3 > dir, T half_angle_radians)
 
Vec< T, 3 > solidcap (Vec< T, 3 > dir, T half_angle_radians, T minR, T maxR)
 
Vec< T, 3 > oriented_disk (Vec< T, 3 > normal, T r)
 
Vec< T, 3 > box (T minx, T miny, T minz, T maxx, T maxy, T maxz)
 
Vec< T, 2 > disk ()
 
Vec< T, 2 > disk (T radius)
 
Vec< T, 2 > arc (T min_radians, T max_radians)
 
Vec< T, 2 > solidarc (T min_radians, T max_radians, T min_radius, T max_radius)
 
Vec< T, 2 > box (T minx, T miny, T maxx, T maxy)
 

Public Attributes

Randomrng
 

Detailed Description

template<typename T>
class geom::Sampler< T >

A class for randomly sampling a variety of regions over RN space.

Example

A random vector of unit length may be generated by:

Random *rng = new MTRand(mySeed);
Sampler<double> rvg(rng);
Vec<double,3> p = rvg.unit<3>();

Constructor & Destructor Documentation

◆ Sampler() [1/2]

Sampler ( )
inline

Construct a new Sampler using the default (non-reentrant) pseudorandom number generator as the source of random bits.

◆ Sampler() [2/2]

Sampler ( Random rng)
inline

Construct a new Sampler with the supplied random number generator as the source of random bits.

Parameters
rngA (pseudo-) random number generator.

Member Function Documentation

◆ arc()

Vec< T, 2 > arc ( min_radians,
max_radians 
)
inline

Generate a unit 2D vector with random angle. The entire rangle of angles between min_radians and max_radians may be sampled, so consider whether to use a negative minimum for ranges of direction which cross the +x axis.

Parameters
min_radiansMinimum angle of generated vector counterclockwise from the +x axis, in radians.
max_radiansMaximum angle of generated vector counterclockwise from the +x axis, in radians.
Returns
A random 2D vector of unit length with heading between min_radians and max_radians.

◆ box() [1/5]

Vec< T, N > box ( )
inline
Template Parameters
NDimension of generated sample.
Returns
A random vector inside the box (0, 1)N.

◆ box() [2/5]

Vec< T, N > box ( const Rect< T, N > &  box)
inline
Template Parameters
NDimension of generated sample.
Parameters
boxRegion to sample.
Returns
A random vector inside the provided region.

◆ box() [3/5]

Vec< T, 2 > box ( minx,
miny,
maxx,
maxy 
)
inline
Returns
A random 2D vector inside the axis-aligned box bounded by the provided coordinates.

◆ box() [4/5]

Vec< T, 3 > box ( minx,
miny,
minz,
maxx,
maxy,
maxz 
)
inline
Returns
A random 3D vector inside the axis-aligned box bounded by the provided coordinates.

◆ box() [5/5]

Vec< T, N > box ( Vec< T, N >  lo,
Vec< T, N >  hi 
)
inline
Template Parameters
NDimension of generated sample.
Parameters
loMinimum coordinates of sample.
hiMaximum coordinates of sample.
Returns
A random vector inside the rectangle bounded by lo and hi.

◆ cap() [1/2]

Vec< T, 3 > cap ( half_angle_radians)
inline
Parameters
half_angle_radiansAngle from the z+ axis to the cap's edge.
Returns
A random 3D vector of unit length uniformly distributed over the spherical cap with internal angle half_angle_radians.

◆ cap() [2/2]

Vec< T, 3 > cap ( Vec< T, 3 >  dir,
half_angle_radians 
)
inline
Parameters
dirDirection about which to sample.
half_angle_radiansAngle from dir to sample within.
Returns
A random 3D vector of unit length uniformly distributed over the spherical cap with center along direction dir, with angle half_angle_radians between the axis and edge of the cap.

◆ disk() [1/2]

Vec< T, 2 > disk ( )
inline

Synonym for solidball<2>().

Returns
A random 2D vector inside a circle with radius 1 and centered at the origin. Samples are uniformly distributed across the area of the disk.

◆ disk() [2/2]

Vec< T, 2 > disk ( radius)
inline

Synonym for solidball<2>(T).

Parameters
radius
Returns
A random 2D vector inside a circle with radius r and centered at the origin. Samples are uniformly distributed across the area of the disk.

◆ oriented_disk()

Vec< T, 3 > oriented_disk ( Vec< T, 3 >  normal,
r 
)
inline
Parameters
normalNormal of the disk to sample.
rRadius of disk to sample.
Returns
A random 3D vector on the surface of a disk of radius r and normal n.

◆ shell()

Vec< T, N > shell ( minradius,
maxradius 
)
inline
Template Parameters
NDimension of generated sample.
Parameters
minradiusMinimum length of generated sample.
maxradiusMaximum length of generated sample.
Returns
A random vector between the surfaces of two co-centric spheres of differing radius. Samples are uniformly distributed throughout the volume.

◆ solidarc()

Vec< T, 2 > solidarc ( min_radians,
max_radians,
min_radius,
max_radius 
)
inline

Generate a 2D vector with random angle and a random length. The entire rangle of angles between min_radians and max_radians may be sampled, so consider whether to use a negative minimum for ranges of direction which cross the +x axis. The generated samples will be uniformly distributed throughout the sampled area.

Parameters
min_radiansMinimum angle of generated vector counterclockwise from the +x axis, in radians.
max_radiansMaximum angle of generated vector counterclockwise from the +x axis, in radians.
min_radiusMinimum length of generated vector.
max_radiusMaximum length of generated vector.
Returns
A random 2D vector of length between min_radius and max_radius and heading between min_radians and max_radians.

◆ solidball() [1/2]

Vec< T, N > solidball ( )
inline
Template Parameters
NDimension of generated sample.
Returns
A random vector inside the unit sphere. Samples are uniformly distributed throughout the volume.

◆ solidball() [2/2]

Vec< T, N > solidball ( radius)
inline
Template Parameters
NDimension of generated sample.
Parameters
radiusRadius of sphere in which to sample.
Returns
A random vector inside the sphere of radius radius. Samples are uniformly distributed throughout the volume.

◆ solidcap()

Vec< T, 3 > solidcap ( Vec< T, 3 >  dir,
half_angle_radians,
minR,
maxR 
)
inline
Parameters
dirDirection about which to sample.
half_angle_radiansAngle from dir to sample within.
minRMinimum distance of sample from origin.
maxRMaximum distance of sample from origin.
Returns
A random 3D vector inside the cone with axial angle half_angle_radians and between the surfaces of two spheres with radii minR and maxR, uniformly distributed throughout the volume.

◆ unit() [1/2]

Vec< T, N > unit ( )
inline
Template Parameters
NDimension of generated sample.
Returns
A random vector of unit length. Distribution is uniform over the surface of the RN sphere.

◆ unit() [2/2]

Vec< T, N > unit ( radius)
inline
Template Parameters
NDimension of generated sample.
Parameters
radiusLength of generated vector.
Returns
A random vector with length radius. Distribution is uniform over the surface of the RN sphere.

The documentation for this class was generated from the following file: