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 > | |
T | CS::Math::Noise::GetMax (const T &a, const T &b) |
Returns the maximum of two values. | |
template<class T > | |
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:
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.
T CS::Math::Noise::GetMax | ( | const T & | a, | |
const T & | b | |||
) | [inline] |
T CS::Math::Noise::GetMin | ( | const T & | a, | |
const T & | b | |||
) | [inline] |
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.
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] |
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
void CS::Math::Noise::SwapValues | ( | T & | a, | |
T & | b | |||
) | [inline] |
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 |
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.0 by doxygen 1.6.1