|
MFCPP
1.0
|
Corentin Chauvin-Hameau – 2019-2020
|
|
Coverage Path Planning for an underwater robot surveying a marine farm
|
|
Perlin noise generator. More...
#include <perlin_noise.hpp>
Classes | |
| struct | Vec2d |
| Two dimensional vector. More... | |
Public Member Functions | |
| PerlinNoiseGenerator () | |
| Default constructor. More... | |
| PerlinNoiseGenerator (float height, float width, unsigned int n_height, unsigned int n_width, unsigned long int seed=0) | |
| Constructor initialising the generator with the given parameters. More... | |
| ~PerlinNoiseGenerator () | |
| void | configure (float height, float width, unsigned int n_height, unsigned int n_width, unsigned long int seed=0) |
| Configures the generator. More... | |
| void | randomise_gradients () |
| Fills the hash list with random gradients. More... | |
| void | generate (unsigned long int seed=0) |
| Populates the grid with random gradients from the hash list. More... | |
| double | evaluate (float x, float y) const |
| Evaluates the perlin noise at a given position. More... | |
| float | accentuate (float x) const |
| Applies a polynomial to accentuate the given value. More... | |
Private Member Functions | |
| void | init_random (unsigned long int seed) |
| Initialises random generation. More... | |
| float | dot_product (Vec2d u, Vec2d v) const |
| Computes the dot product between two vectors. More... | |
| 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. More... | |
| float | interpolate (float a, float b, float t) const |
| Linear interpolation between two values. More... | |
| float | fade (float t) const |
| Sixth order polynomial to smooth the noise. More... | |
Private Attributes | |
| float | height_ |
| Height of the 2D space in which to generate the noise. More... | |
| float | width_ |
| Width of the 2D space in which to generate the noise. More... | |
| unsigned int | n_height_ |
| Size of the discretised grid in the first dimension. More... | |
| unsigned int | n_width_ |
| Size of the discretised grid in the second dimension. More... | |
| std::vector< std::vector< Vec2d > > | gradients_ |
| Gradients evaluated at nodes of the grid. More... | |
| std::vector< Vec2d > | hash_gradients_ |
| Hash list of random gradients. More... | |
| bool | randomise_seed_ |
| Whether to randomise seeding for random numbers. More... | |
| unsigned long int | seed_ |
| Seed for random numbers when no random seeding. More... | |
| std::random_device | random_device_ |
| Seed initialiser for generation of random numbers. More... | |
Perlin noise generator.
Definition at line 21 of file perlin_noise.hpp.
| mfcpp::PerlinNoiseGenerator::PerlinNoiseGenerator | ( | ) |
Default constructor.
Definition at line 56 of file perlin_noise.cpp.
| mfcpp::PerlinNoiseGenerator::PerlinNoiseGenerator | ( | float | height, |
| float | width, | ||
| unsigned int | n_height, | ||
| unsigned int | n_width, | ||
| unsigned long int | seed = 0 |
||
| ) |
Constructor initialising the generator with the given parameters.
| height | Height of the 2D space in which to generate the noise |
| width | Width of the 2D space in which to generate the noise |
| n_height | Size of the discretised grid in the first dimension |
| n_width | Size of the discretised grid in the second dimensio |
| seed | Seed for randomisation (0 for random seeding) |
Definition at line 67 of file perlin_noise.cpp.
| mfcpp::PerlinNoiseGenerator::~PerlinNoiseGenerator | ( | ) |
Definition at line 80 of file perlin_noise.cpp.
|
inline |
Applies a polynomial to accentuate the given value.
Values under 0.5 are pushed towards 0, while values above 0.5 are pushed towards 1.
| x | Given value |
Definition at line 195 of file perlin_noise.hpp.
| void mfcpp::PerlinNoiseGenerator::configure | ( | float | height, |
| float | width, | ||
| unsigned int | n_height, | ||
| unsigned int | n_width, | ||
| unsigned long int | seed = 0 |
||
| ) |
Configures the generator.
| height | Height of the 2D space in which to generate the noise |
| width | Width of the 2D space in which to generate the noise |
| n_height | Size of the discretised grid in the first dimension |
| n_width | Size of the discretised grid in the second dimension |
| seed | Seed for randomisation (0 for random seeding) |
Definition at line 86 of file perlin_noise.cpp.
|
private |
Compute the dot product of the distance vector to the node an the gradient at this node.
| i | Index of the node for the first dimension |
| j | Index of the node for the second dimension |
| x | First coordinate of the evaluated point |
| y | Second coordinate of the evaluated point |
Definition at line 210 of file perlin_noise.cpp.
Computes the dot product between two vectors.
| u | First vector |
| v | Second vector |
Definition at line 204 of file perlin_noise.cpp.
| double mfcpp::PerlinNoiseGenerator::evaluate | ( | float | x, |
| float | y | ||
| ) | const |
Evaluates the perlin noise at a given position.
| x | First coordinate where to evaluate |
| y | Second coordinate where to evaluate |
Definition at line 152 of file perlin_noise.cpp.
|
inlineprivate |
Sixth order polynomial to smooth the noise.
| t | Number between 0 and 1 |
Definition at line 189 of file perlin_noise.hpp.
| void mfcpp::PerlinNoiseGenerator::generate | ( | unsigned long int | seed = 0 | ) |
Populates the grid with random gradients from the hash list.
| seed | Seed for randomisation (0 for random seeding) |
Definition at line 128 of file perlin_noise.cpp.
|
private |
Initialises random generation.
| seed | Seed to use for initialisation. If 0, random seeding |
Definition at line 192 of file perlin_noise.cpp.
|
private |
Linear interpolation between two values.
| a | First value to interpolate |
| b | Second value to interpolate |
| t | Interpolation ratio |
Definition at line 220 of file perlin_noise.cpp.
| void mfcpp::PerlinNoiseGenerator::randomise_gradients | ( | ) |
Fills the hash list with random gradients.
Definition at line 99 of file perlin_noise.cpp.
|
private |
Gradients evaluated at nodes of the grid.
Definition at line 124 of file perlin_noise.hpp.
|
private |
Hash list of random gradients.
Definition at line 127 of file perlin_noise.hpp.
|
private |
Height of the 2D space in which to generate the noise.
Definition at line 112 of file perlin_noise.hpp.
|
private |
Size of the discretised grid in the first dimension.
Definition at line 118 of file perlin_noise.hpp.
|
private |
Size of the discretised grid in the second dimension.
Definition at line 121 of file perlin_noise.hpp.
|
private |
Seed initialiser for generation of random numbers.
Definition at line 136 of file perlin_noise.hpp.
|
private |
Whether to randomise seeding for random numbers.
Definition at line 130 of file perlin_noise.hpp.
|
private |
Seed for random numbers when no random seeding.
Definition at line 133 of file perlin_noise.hpp.
|
private |
Width of the 2D space in which to generate the noise.
Definition at line 115 of file perlin_noise.hpp.
1.8.11