CrystalSpace

Public API Reference

libnoise

Classes

struct  CS::Math::Noise::Module::ControlPoint
 This structure defines a control point. More...

Modules

 Models
 Noise Modules

Enumerations

enum  CS::Math::Noise::NoiseQuality { CS::Math::Noise::QUALITY_FAST = 0, CS::Math::Noise::QUALITY_STD = 1, CS::Math::Noise::QUALITY_BEST = 2 }
 

Enumerates the noise quality.

More...

Functions

double CS::Math::Noise::CubicInterp (double n0, double n1, double n2, double n3, double a)
 Performs cubic interpolation between two values bound between two other values.
template<class T >
CS::Math::Noise::GetMax (const T &a, const T &b)
 Returns the maximum of two values.
template<class T >
CS::Math::Noise::GetMin (const T &a, const T &b)
 Returns the minimum of two values.
double CS::Math::Noise::GradientCoherentNoise3D (double x, double y, double z, int seed=0, NoiseQuality noiseQuality=QUALITY_STD)
 Generates a gradient-coherent-noise value from the coordinates of a three-dimensional input value.
double CS::Math::Noise::GradientNoise3D (double fx, double fy, double fz, int ix, int iy, int iz, int seed=0)
 Generates a gradient-noise value from the coordinates of a three-dimensional input value and the integer coordinates of a nearby three-dimensional value.
int CS::Math::Noise::IntValueNoise3D (int x, int y, int z, int seed=0)
 Generates an integer-noise value from the coordinates of a three-dimensional input value.
void CS::Math::Noise::LatLonToXYZ (double lat, double lon, double &x, double &y, double &z)
 Converts latitude/longitude coordinates on a unit sphere into 3D Cartesian coordinates.
double CS::Math::Noise::LinearInterp (double n0, double n1, double a)
 Performs linear interpolation between two values.
double CS::Math::Noise::MakeInt32Range (double n)
 Modifies a floating-point value so that it can be stored in a CS::Math::Noise::int32 variable.
double CS::Math::Noise::SCurve3 (double a)
 Maps a value onto a cubic S-curve.
double CS::Math::Noise::SCurve5 (double a)
 Maps a value onto a quintic S-curve.
template<class T >
void CS::Math::Noise::SwapValues (T &a, T &b)
 Swaps two values.
double CS::Math::Noise::ValueCoherentNoise3D (double x, double y, double z, int seed=0, NoiseQuality noiseQuality=QUALITY_STD)
 Generates a value-coherent-noise value from the coordinates of a three-dimensional input value.
double CS::Math::Noise::ValueNoise3D (int x, int y, int z, int seed=0)
 Generates a value-noise value from the coordinates of a three-dimensional input value.

Variables

const double CS::Math::Noise::DEG_TO_RAD = PI / 180.0
 Converts an angle from degrees to radians.
const double CS::Math::Noise::RAD_TO_DEG = 1.0 / DEG_TO_RAD
 Converts an angle from radians to degrees.
const double CS::Math::Noise::SQRT_2 = 1.4142135623730950488
 Pi.
const double CS::Math::Noise::SQRT_3 = 1.7320508075688772935
 Square root of 3.

Enumeration Type Documentation

Enumerates the noise quality.

Enumerator:
QUALITY_FAST 

Generates coherent noise quickly.

When a coherent-noise function with this quality setting is used to generate a bump-map image, there are noticeable "creasing" artifacts in the resulting image. This is because the derivative of that function is discontinuous at integer boundaries.

QUALITY_STD 

Generates standard-quality coherent noise.

When a coherent-noise function with this quality setting is used to generate a bump-map image, there are some minor "creasing" artifacts in the resulting image. This is because the second derivative of that function is discontinuous at integer boundaries.

QUALITY_BEST 

Generates the best-quality coherent noise.

When a coherent-noise function with this quality setting is used to generate a bump-map image, there are no "creasing" artifacts in the resulting image. This is because the first and second derivatives of that function are continuous at integer boundaries.

Definition at line 37 of file noisegen.h.


Function Documentation

double CS::Math::Noise::CubicInterp ( double  n0,
double  n1,
double  n2,
double  n3,
double  a 
) [inline]

Performs cubic interpolation between two values bound between two other values.

Parameters:
n0 The value before the first value.
n1 The first value.
n2 The second value.
n3 The value after the second value.
a The alpha value.
Returns:
The interpolated value.

The alpha value should range from 0.0 to 1.0. If the alpha value is 0.0, this function returns n1. If the alpha value is 1.0, this function returns n2.

Definition at line 47 of file interp.h.

template<class T >
T CS::Math::Noise::GetMax ( const T &  a,
const T &  b 
) [inline]

Returns the maximum of two values.

Parameters:
a The first value.
b The second value.
Returns:
The maximum of the two values.

Definition at line 63 of file misc.h.

template<class T >
T CS::Math::Noise::GetMin ( const T &  a,
const T &  b 
) [inline]

Returns the minimum of two values.

Parameters:
a The first value.
b The second value.
Returns:
The minimum of the two values.

Definition at line 75 of file misc.h.

double CS::Math::Noise::GradientCoherentNoise3D ( double  x,
double  y,
double  z,
int  seed = 0,
NoiseQuality  noiseQuality = QUALITY_STD 
)

Generates a gradient-coherent-noise value from the coordinates of a three-dimensional input value.

Parameters:
x The x coordinate of the input value.
y The y coordinate of the input value.
z The z coordinate of the input value.
seed The random number seed.
noiseQuality The quality of the coherent-noise.
Returns:
The generated gradient-coherent-noise value.

The return value ranges from -1.0 to +1.0.

For an explanation of the difference between gradient noise and value noise, see the comments for the GradientNoise3D() function.

double CS::Math::Noise::GradientNoise3D ( double  fx,
double  fy,
double  fz,
int  ix,
int  iy,
int  iz,
int  seed = 0 
)

Generates a gradient-noise value from the coordinates of a three-dimensional input value and the integer coordinates of a nearby three-dimensional value.

Parameters:
fx The floating-point x coordinate of the input value.
fy The floating-point y coordinate of the input value.
fz The floating-point z coordinate of the input value.
ix The integer x coordinate of a nearby value.
iy The integer y coordinate of a nearby value.
iz The integer z coordinate of a nearby value.
seed The random number seed.
Returns:
The generated gradient-noise value.
Precondition:
The difference between fx and ix must be less than or equal to one.
The difference between fy and iy must be less than or equal to one.
The difference between fz and iz must be less than or equal to one.

A gradient-noise function generates better-quality noise than a value-noise function. Most noise modules use gradient noise for this reason, although it takes much longer to calculate.

The return value ranges from -1.0 to +1.0.

This function generates a gradient-noise value by performing the following steps:

  • It first calculates a random normalized vector based on the nearby integer value passed to this function.
  • It then calculates a new value by adding this vector to the nearby integer value passed to this function.
  • It then calculates the dot product of the above-generated value and the floating-point input value passed to this function.

A noise function differs from a random-number generator because it always returns the same output value if the same input value is passed to it.

int CS::Math::Noise::IntValueNoise3D ( int  x,
int  y,
int  z,
int  seed = 0 
)

Generates an integer-noise value from the coordinates of a three-dimensional input value.

Parameters:
x The integer x coordinate of the input value.
y The integer y coordinate of the input value.
z The integer z coordinate of the input value.
seed A random number seed.
Returns:
The generated integer-noise value.

The return value ranges from 0 to 2147483647.

A noise function differs from a random-number generator because it always returns the same output value if the same input value is passed to it.

void CS::Math::Noise::LatLonToXYZ ( double  lat,
double  lon,
double &  x,
double &  y,
double &  z 
)

Converts latitude/longitude coordinates on a unit sphere into 3D Cartesian coordinates.

Parameters:
lat The latitude, in degrees.
lon The longitude, in degrees.
x On exit, this parameter contains the x coordinate.
y On exit, this parameter contains the y coordinate.
z On exit, this parameter contains the z coordinate.
Precondition:
lat must range from -90 to +90.
lon must range from -180 to +180.
double CS::Math::Noise::LinearInterp ( double  n0,
double  n1,
double  a 
) [inline]

Performs linear interpolation between two values.

Parameters:
n0 The first value.
n1 The second value.
a The alpha value.
Returns:
The interpolated value.

The alpha value should range from 0.0 to 1.0. If the alpha value is 0.0, this function returns n0. If the alpha value is 1.0, this function returns n1.

Definition at line 68 of file interp.h.

double CS::Math::Noise::MakeInt32Range ( double  n  )  [inline]

Modifies a floating-point value so that it can be stored in a CS::Math::Noise::int32 variable.

Parameters:
n A floating-point number.
Returns:
The modified floating-point number.

This function does not modify n.

In libnoise, the noise-generating algorithms are all integer-based; they use variables of type CS::Math::Noise::int32. Before calling a noise function, pass the x, y, and z coordinates to this function to ensure that these coordinates can be cast to a CS::Math::Noise::int32 value.

Although you could do a straight cast from double to CS::Math::Noise::int32, the resulting value may differ between platforms. By using this function, you ensure that the resulting value is identical between platforms.

Definition at line 159 of file noisegen.h.

double CS::Math::Noise::SCurve3 ( double  a  )  [inline]

Maps a value onto a cubic S-curve.

Parameters:
a The value to map onto a cubic S-curve.
Returns:
The mapped value.

a should range from 0.0 to 1.0.

The derivitive of a cubic S-curve is zero at a = 0.0 and a = 1.0

Definition at line 83 of file interp.h.

double CS::Math::Noise::SCurve5 ( double  a  )  [inline]

Maps a value onto a quintic S-curve.

Parameters:
a The value to map onto a quintic S-curve.
Returns:
The mapped value.

a should range from 0.0 to 1.0.

The first derivitive of a quintic S-curve is zero at a = 0.0 and a = 1.0

The second derivitive of a quintic S-curve is zero at a = 0.0 and a = 1.0

Definition at line 101 of file interp.h.

template<class T >
void CS::Math::Noise::SwapValues ( T &  a,
T &  b 
) [inline]

Swaps two values.

Parameters:
a A variable containing the first value.
b A variable containing the second value.
Postcondition:
The values within the the two variables are swapped.

Definition at line 87 of file misc.h.

double CS::Math::Noise::ValueCoherentNoise3D ( double  x,
double  y,
double  z,
int  seed = 0,
NoiseQuality  noiseQuality = QUALITY_STD 
)

Generates a value-coherent-noise value from the coordinates of a three-dimensional input value.

Parameters:
x The x coordinate of the input value.
y The y coordinate of the input value.
z The z coordinate of the input value.
seed The random number seed.
noiseQuality The quality of the coherent-noise.
Returns:
The generated value-coherent-noise value.

The return value ranges from -1.0 to +1.0.

For an explanation of the difference between gradient noise and value noise, see the comments for the GradientNoise3D() function.

double CS::Math::Noise::ValueNoise3D ( int  x,
int  y,
int  z,
int  seed = 0 
)

Generates a value-noise value from the coordinates of a three-dimensional input value.

Parameters:
x The x coordinate of the input value.
y The y coordinate of the input value.
z The z coordinate of the input value.
seed A random number seed.
Returns:
The generated value-noise value.

The return value ranges from -1.0 to +1.0.

A noise function differs from a random-number generator because it always returns the same output value if the same input value is passed to it.


Variable Documentation

const double CS::Math::Noise::DEG_TO_RAD = PI / 180.0

Converts an angle from degrees to radians.

Definition at line 48 of file mathconsts.h.

const double CS::Math::Noise::RAD_TO_DEG = 1.0 / DEG_TO_RAD

Converts an angle from radians to degrees.

Definition at line 51 of file mathconsts.h.

const double CS::Math::Noise::SQRT_2 = 1.4142135623730950488

Pi.

Square root of 2.

Definition at line 42 of file mathconsts.h.

const double CS::Math::Noise::SQRT_3 = 1.7320508075688772935

Square root of 3.

Definition at line 45 of file mathconsts.h.


Generated for Crystal Space 2.1 by doxygen 1.6.1