9 #ifndef PERLIN_NOISE_HPP 10 #define PERLIN_NOISE_HPP 38 unsigned int n_width,
unsigned long int seed=0);
51 void configure(
float height,
float width,
unsigned int n_height,
52 unsigned int n_width,
unsigned long int seed=0);
64 void generate(
unsigned long int seed=0);
73 double evaluate(
float x,
float y)
const;
95 Vec2d(
float _x,
float _y);
163 float dot_dist_grad(
unsigned int i,
unsigned int j,
float x,
float y)
const;
173 float interpolate(
float a,
float b,
float t)
const;
182 inline float fade(
float t)
const;
191 return t * t * t * (t * (t * 6 - 15) + 10);
float norm2()
Computes the square of the euclidean norm of the vector.
float fade(float t) const
Sixth order polynomial to smooth the noise.
std::vector< std::vector< Vec2d > > gradients_
Gradients evaluated at nodes of the grid.
float dot_product(Vec2d u, Vec2d v) const
Computes the dot product between two vectors.
void operator=(const Vec2d &a)
void init_random(unsigned long int seed)
Initialises random generation.
float height_
Height of the 2D space in which to generate the noise.
float width_
Width of the 2D space in which to generate the noise.
float interpolate(float a, float b, float t) const
Linear interpolation between two values.
void configure(float height, float width, unsigned int n_height, unsigned int n_width, unsigned long int seed=0)
Configures the generator.
unsigned int n_height_
Size of the discretised grid in the first dimension.
bool randomise_seed_
Whether to randomise seeding for random numbers.
float y
Second coordinate.
std::random_device random_device_
Seed initialiser for generation of random numbers.
float accentuate(float x) const
Applies a polynomial to accentuate the given value.
void generate(unsigned long int seed=0)
Populates the grid with random gradients from the hash list.
unsigned int n_width_
Size of the discretised grid in the second dimension.
unsigned long int seed_
Seed for random numbers when no random seeding.
void randomise_gradients()
Fills the hash list with random gradients.
std::vector< Vec2d > hash_gradients_
Hash list of random gradients.
float dot_dist_grad(unsigned int i, unsigned int j, float x, float y) const
Compute the dot product of the distance vector to the node an the gradient at this node...
PerlinNoiseGenerator()
Default constructor.
float norm()
Computes the euclidean norm of the vector.
double evaluate(float x, float y) const
Evaluates the perlin noise at a given position.