Core 1.0
SimplexTurbulence2 Class Reference

Fractal Brownian motion from a simplex noise function. More...

#include <turbulence.h>

Inheritance diagram for SimplexTurbulence2:
SimplexNoise2 AnalyticScalarField2

Public Member Functions

 SimplexTurbulence2 ()
 Unit turbulence.
 SimplexTurbulence2 (const double &, const double &, const double &, const double &=0.5, const double &=0.5, int=8, const Vector2 &=Vector2::Null)
 Create a scaled turbulence.
 ~SimplexTurbulence2 ()
 Empty.
double Value (const Vector2 &) const
 Compute the simplex turbulence at a given point.
double GetAmplitude () const
 Return the amplitude of the turbulence.
double GetWavelength () const
 Return the base wavelength of the turbulence.
double GetAlpha () const
 Return the amplitude dampening coefficient.
double GetLambda () const
 Return the wavelength dampening coefficient.
int GetOctaves () const
 Number of octaves.
double K () const
 Return the global Lipschitz constant.
double Maximum () const
 Return the maximum of the turbulence.
SimplexTurbulence2 SetNullAt (const Vector2 &) const
 Change the base value of the turbulence so that it is zero at the given point.
virtual ScalarField2 Sample (const Array2 &) const
 Create a discrete scalar field by sampling a given domain.

Protected Member Functions

double UnitAt (const Vector2 &) const
 Compute the unit turbulence value at a given point.
Protected Member Functions inherited from SimplexNoise2
 SimplexNoise2 ()
 Empty.
 ~SimplexNoise2 ()
 Empty.
double K () const
 Return the global Lipschitz constant of the noise.
Protected Member Functions inherited from AnalyticScalarField2
Matrix Local (const Vector2 &) const
 Compute the local neighborhood in the one-ring aroung a point.
 AnalyticScalarField2 (bool=true)
 Constructor.
virtual Vector2 Gradient (const Vector2 &) const
 Compute the gradient of the field.
virtual Matrix2 Hessian (const Vector2 &) const
 Compute the hessian at a given point.
bool Inside (const double &) const
 Check if the value is considered as inside or outside.
void Curvature (const Vector2 &, double &, double &) const
 Compute the gaussian and mean curvatures.
virtual Box2 GetBox () const
 Return the bounding box.

Protected Attributes

double alpha = 0.5
 Amplitude attenuation coefficient.
double lambda = 0.5
 Wavelength amplification coefficient.
int octaves = 8
 Number of octaves.
Vector2 t = Vector2::Null
 Translation.
double v0 = 0.0
 Base value.
double a0 = 1.0
 Base amplitude.
double l0 = 1.0
 Wavelength.
Protected Attributes inherited from AnalyticScalarField2
bool sign = true
 Sign convention, used for normal computation.
Box2 box = Box2::Infinity
 Domain, set as infinite for base class.

Static Protected Attributes

static const Matrix2 R2 = Matrix2::Rotation(4.0 * Math::Pi / 19.0)
 Random incremental rotation in the plane.
Static Protected Attributes inherited from SimplexNoise2
static const Vector2 grad2 [8]
 Array of gradients.
static const int perm [512]
 Permutation table, 256 entries duplicated once to avoid modulo computations.
static const double G2 = (3.0 - sqrt(3.0)) / 6.0
 Unskew factors for planar case.
Static Protected Attributes inherited from AnalyticScalarField2
static const double epsilon = 1e-6
 \( \varepsilon \) value for first order partial derivatives (gradient).
static const double epsilonhessian = 1e-4
 Larger \( \varepsilon \) value for second order partial derivatives (hessian).

Friends

std::ostream & operator<< (std::ostream &s, const SimplexTurbulence2 &noise)
 Overloaded.

Detailed Description

Fractal Brownian motion from a simplex noise function.

A turbulence field is characterized by the number of octaves, the attenuation of the amplitude of the noise summed at every step, and by the amplification of the wavelength.

Constructor & Destructor Documentation

◆ SimplexTurbulence2()

SimplexTurbulence2::SimplexTurbulence2 ( const double & v,
const double & a,
const double & l,
const double & alpha = 0.5,
const double & lambda = 0.5,
int octaves = 8,
const Vector2 & t = Vector2::Null )
explicit

Create a scaled turbulence.

Parameters
v,a,lBase value, amplitude and wavelength.
alphaAmplitude attenuation factor (~0.5, should be less than 1.0).
lambdaWavelength attenuation factor (~0.5, should be less than 1.0).
octavesNumber of octaves.
tTranslation offset, in units of the base wavelength: it is subtracted from the point after its division by the wavelength l, so that the translation is t l in the units of the points. This differs from the noise turbulence, where the offset is in the units of the points.

Member Function Documentation

◆ K()

double SimplexTurbulence2::K ( ) const

Return the global Lipschitz constant.

See also
Noise::K()

◆ Sample()

ScalarField2 AnalyticScalarField2::Sample ( const Array2 & a) const
virtual

Create a discrete scalar field by sampling a given domain.

Parameters
aDomain.

Reimplemented from AnalyticScalarField2.

◆ SetNullAt()

SimplexTurbulence2 SimplexTurbulence2::SetNullAt ( const Vector2 & p) const

Change the base value of the turbulence so that it is zero at the given point.

Parameters
pPoint.

◆ UnitAt()

double SimplexTurbulence2::UnitAt ( const Vector2 & p) const
protected

Compute the unit turbulence value at a given point.

Sums a series of scaled noise functions.

Parameters
pPoint, already divided by the base wavelength, which is the case of the point translated by the offset of the turbulence.

◆ Value()

double SimplexTurbulence2::Value ( const Vector2 & p) const
virtual

Compute the simplex turbulence at a given point.

Parameters
pPoint.

Reimplemented from SimplexNoise2.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const SimplexTurbulence2 & noise )
friend

Overloaded.

Parameters
sStream.
noiseThe noise.