vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
APNature::TerrainRandom Class Reference

#include <TerrainRandom.h>

Static Public Member Functions

static float GetRandomFloatUniform (float from, float to)
 
static float GetRandomFloatGaussian (float mean, float standardDeviation)
 
static float GetRandomFloatGaussianBasedOnPointDistance (int x1, int y1, int x2, int y2)
 

Member Function Documentation

float TerrainRandom::GetRandomFloatGaussian ( float  mean,
float  standardDeviation 
)
static

Returns a pseudo-random float given by a normal distribution specified by its statistical parameters. Based on the Marsaglia polar method (more efficient Box-Muller algorithm).

[Inspired] by sample implementation from http://en.wikipedia.org/wiki/Marsaglia_polar_method

Parameters
[in]meanMean value of the normal distribution.
[in]standardDeviationStandard deviation of the normal distribution.
[in]Pseudo-randomfloat given by normal distribution.
float TerrainRandom::GetRandomFloatGaussianBasedOnPointDistance ( int  x1,
int  y1,
int  x2,
int  y2 
)
static

Return a pseudo-random gaussian number with a normal distribution with standard deviation proportionate to the point distance on the surface. The closer the points are, the smaller the standard deviation is and vice versa.

[Corrected] formula taken from Modern Computer Graphics (2004), page 279.

Parameters
[in]x1X-coordinate of the first point.
[in]y1Y-coordinate of the first point.
[in]x2X-coordinate of the second point.
[in]y2Y-coordinate of the second point.
Returns
Pseudo-random float generated with normal distribution dependent on point distance.
static float APNature::TerrainRandom::GetRandomFloatUniform ( float  from,
float  to 
)
inlinestatic

Returns a pseudo-random float from the interval given by its boundaries (boundaries included) with a uniform probability distribution. Sampling of the float values depends on value RAND_MAX from the standard library (theoretically RAND_MAX possible results).

Parameters
[in]fromLower interval boundary.
[in]toUpper interval boundary.
Returns
Pseudo-random float from the interval given by its boundaries.

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