C# Class Accord.Math.PerlinNoise

Perlin noise function.

The class implements 1-D and 2-D Perlin noise functions, which represent sum of several smooth noise functions with different frequency and amplitude. The description of Perlin noise function and its calculation may be found on Hugo Elias's page.

The number of noise functions, which comprise the resulting Perlin noise function, is set by Octaves property. Amplitude and frequency values for each octave start from values, which are set by InitFrequency and InitAmplitude properties.

Sample usage (clouds effect):

// create Perlin noise function PerlinNoise noise = new PerlinNoise( 8, 0.5, 1.0 / 32 ); // generate clouds effect float[,] texture = new float[height, width]; for ( int y = 0; y < height; y++ ) { for ( int x = 0; x < width; x++ ) { texture[y, x] = Math.Max( 0.0f, Math.Min( 1.0f, (float) noise.Function2D( x, y ) * 0.5f + 0.5f ) ); } }
Afficher le fichier Open project: accord-net/framework

Méthodes publiques

Méthode Description
Function ( double x ) : double

1-D Perlin noise function.

Function2D ( double x, double y ) : double

2-D Perlin noise function.

PerlinNoise ( ) : System

Initializes a new instance of the PerlinNoise class.

PerlinNoise ( int octaves, double persistence ) : System

Initializes a new instance of the PerlinNoise class.

PerlinNoise ( int octaves, double persistence, double initFrequency, double initAmplitude ) : System

Initializes a new instance of the PerlinNoise class.

Private Methods

Méthode Description
CosineInterpolate ( double x1, double x2, double a ) : double

Cosine interpolation.

Noise ( int x ) : double

Ordinary noise function

Noise ( int x, int y ) : double
SmoothedNoise ( double x ) : double

Smoothed noise.

SmoothedNoise ( double x, double y ) : double

Method Details

Function() public méthode

1-D Perlin noise function.
public Function ( double x ) : double
x double x value.
Résultat double

Function2D() public méthode

2-D Perlin noise function.
public Function2D ( double x, double y ) : double
x double x value.
y double y value.
Résultat double

PerlinNoise() public méthode

Initializes a new instance of the PerlinNoise class.
public PerlinNoise ( ) : System
Résultat System

PerlinNoise() public méthode

Initializes a new instance of the PerlinNoise class.
public PerlinNoise ( int octaves, double persistence ) : System
octaves int Number of octaves (see property).
persistence double Persistence value (see property).
Résultat System

PerlinNoise() public méthode

Initializes a new instance of the PerlinNoise class.
public PerlinNoise ( int octaves, double persistence, double initFrequency, double initAmplitude ) : System
octaves int Number of octaves (see property).
persistence double Persistence value (see property).
initFrequency double Initial frequency (see property).
initAmplitude double Initial amplitude (see property).
Résultat System