Core 1.0
SimplexTurbulence3D Class Reference

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

#include <turbulence.h>

Inheritance diagram for SimplexTurbulence3D:
SimplexNoise3D AnalyticScalarField

Public Member Functions

 SimplexTurbulence3D (const double &, const double &, const double &, const double &=0.5, const double &=0.5, int=8, const Vector &=Vector::Null)
 Create a scaled turbulence.
 SimplexTurbulence3D ()
 Unit turbulence.
 ~SimplexTurbulence3D ()
 Empty.
double Value (const Vector &) const
 Computes the turbulence value at a given point.
Vector Gradient (const Vector &) const
 Computes the gradient of the turbulence at a given point, analytically.
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.

Protected Member Functions

double UnitAt (const Vector &) const
 Computes the turbulence value at a given point.
Vector UnitGradientAt (const Vector &) const
 Computes the gradient of the unit turbulence at a given point.
Protected Member Functions inherited from SimplexNoise3D
 SimplexNoise3D ()
 Empty.
 ~SimplexNoise3D ()
 Empty.
Protected Member Functions inherited from AnalyticScalarField
bool Find (Vector &, bool, const Box &, int=10000, Xoshiro256 &=Xoshiro256::X512) const
 Find a random sample point inside or outside the surface.
 AnalyticScalarField (bool=true)
 Constructor.
Matrix Hessian (const Vector &) const
 Compute the Hessian symmetric matrix of the field function.
virtual Vector Normal (const Vector &) const
 Compute the normal to the surface.
bool Inside (const double &) const
 Check if the value is considered as inside or outside.
bool Inside (const Box &) const
 Test if a box is inside the implicit surface.
bool Inside (const Sphere &) const
 Test if a sphere is inside the implicit surface.
bool Straddling (const Box &) const
 Test if a box is straddling the implicit surface.
virtual Color GetMaterial (const Vector &, const Vector &=Vector::Null) const
 Compute the color.
virtual Box GetBox () const
 Compute the bounding box of the scalar field.
void Curvature (const Vector &, double &, double &) const
 Compute the gaussian and mean curvatures.
Vector Dichotomy (Vector, Vector, double, double, double, const double &=1.0e-4) const
 Compute the intersection between a segment and an implicit surface.
virtual bool GetSample (Vector &, const Box &, Xoshiro256 &=Xoshiro256::X512) const
 Find a point sample on the implicit surface.
virtual int GetSamples (QVector< Vector > &, const Box &, int, Xoshiro256 &=Xoshiro256::X512) const
 Find a set of random sample points on the implicit surface.
virtual QVector< Vector > Poisson (double, int, Xoshiro256 &=Xoshiro256::X512) const
 Compute a Poisson sphere distribution on an implicit surface.
virtual ScalarField2 Sample (const Rectangles &, int, int) const
 Compute the field function at the vertices a lattice.
virtual ScalarField2 Sample (const Quadrangle &, int) const
 Sample the scalar field on a quadrangle.
virtual ScalarField Sample (const Box &, int) const
 Sample the implicit surface to get a scalar field.
int RootsHHH (const Ray &, const double &, const double &, const double &, double *, int=1, const double &=1.0e-4) const
 Find the intersections between a ray and an implicit surface on a given interval.
int RootsHHH (const Ray &, const double &, const double &, const double &, const double &, const double &, double *, int=1, const double &=1.0e-4) const
 This functions searches the intersections between a ray and an implicit surface on a given interval.
virtual double K (const Box &) const
 Compute the local Lipschitz constant inside a box.
virtual double K (const Sphere &) const
 Compute the local Lipschitz constant inside a box.
virtual double K (const Segment &) const
 Compute the local Lipschitz constant along a segment.
virtual Voxel K (const Box &, int, int, int) const
 Compute the local Lipschitz over a grid.
virtual void Polygonize (int, Mesh &, const Box &, const double &=1e-4) const
 Compute the polygonal mesh approximating the implicit surface.
virtual void PolygonizeLucie (const Box &, Mesh &, bool, bool) const
 Implementation of the original continuation polygonization method.
virtual void PolygonizeLucie (const double &, Mesh &, bool, bool) const
 Wyvill's original marching cubes algorithm.
virtual void Dual (int, Mesh &, const Box &) const
 Dual polygonization.
virtual bool SphereTrace (const Ray &, const double &, const double &, const double &, double &, int &, const double &=1e-4) const
 Find the first intersection between a ray and an implicit surface on a given interval, using sphere tracing.
virtual bool SphereTraceHart (const Ray &, const double &, const double &, const double &, double &, int &, const int &, const double &=1e-4) const
 Find the first intersection between a ray and an implicit surface on a given interval, using basic sphere tracing [Hart 1996] with a limited number of iterations.
virtual bool SphereTraceRelaxed (const Ray &, const double &, const double &, const double &, const double &, double &, int &, int &, const int &, const double &=1e-4) const
 Find the first intersection between a ray and an implicit surface on a given interval, using relaxed sphere tracing [Keinert et al. 2014].
virtual bool SphereTraceEnhanced (const Ray &, const double &, const double &, const double &, const double &, double &, int &, int &, const int &, const double &=1e-4) const
 Find the first intersection between a ray and an implicit surface on a given interval, using enhanced sphere tracing [Balint and Valasek 2018].
virtual void Polygonize (const Box &, QVector< Triangle > &, const double &=1e-4, bool=false) const
 Polygonize a cube.
virtual void Polygonize (const Tetrahedra &, QVector< Triangle > &, const double &=1e-4) const
 Polygonize a tetrahedral cell.
virtual Mesh PolygonizeOctree (const Box &, int, const double &=1e-4) const
 Compute the polygonal mesh approximating the implicit surface using an octree decomposition of space.
virtual void Voxelize (const Box &, int, Box &, QVector< Vector > &) const
 Voxelize the scalar field.
virtual void Voxelize (int, Voxel &, const Box &) const
 Voxelization.
virtual double Volume (int=5) const
 Computes the volume of the BlobTree.
virtual double Volume (const Box &, int) const
 Compute the volume of a BlobTree object.
virtual double Volume (const Box &, int, double &) const
 Compute the volume of an implicit surface.
virtual double StochasticVolume (const Box &, int) const
 Compute the volume of an implicit surface.
virtual Sphere Center (int) const
 Computes the gravity center of the BlobTree.
virtual Sphere Center (const Box &, int) const
 Compute the center of gravity of the BlobTree.
virtual void Colorize (const Mesh &, MeshColor &) const
 Colorize the vertexes of a mesh according to the analytic scalar field.
Vector Cast (const Vector &, const double &, const double &=1e-6, int n=16) const
 Given a starting vertex x, project it onto the implicit surface following the gradient.
virtual void Project (Mesh &, const double &=1e-3, const double &=1e-6, int=16) const
 Project the vertices of a mesh onto the implicit surface.

Protected Attributes

double alpha = 0.5
 Amplitude attenuation coefficient.
double lambda = 0.5
 Wavelength amplification coefficient.
int octaves = 8
 Number of octaves.
Vector t = Vector::Null
 Translation.
double v0 = 0.0
 Base value.
double a0 = 1.0
 Base amplitude.
double l0 = 1.0
 Wavelength.
Protected Attributes inherited from AnalyticScalarField
bool sign = true
 Sign convention, used for normal computation.

Static Protected Attributes

static const Matrix R3 = Matrix::Rotation(Vector(4.0 * Math::Pi / 19.0, 3.0 * Math::Pi / 19.0, 2.0 * Math::Pi / 19.0))
 Random incremental rotation.
Static Protected Attributes inherited from SimplexNoise3D
static const Vector gradient [12]
 Array of gradients for 3D noise.
static const int perm [512]
 Permutation table, 256 entries duplicated once to avoid modulo computations.
static const double G3 = 1.0 / 6.0
 Unskew factors for 3D case.
Static Protected Attributes inherited from AnalyticScalarField
static int ncubes = 0
 Number of cubes processed by polygonization algorithms.
static constexpr double Epsilon = 1e-6
 Epsilon value for partial derivatives.
static constexpr double EpsilonLarge = 1e-4
 Epsilon value for second order partial derivatives.

Friends

std::ostream & operator<< (std::ostream &s, const SimplexTurbulence3D &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

◆ SimplexTurbulence3D()

SimplexTurbulence3D::SimplexTurbulence3D ( const double & v,
const double & a,
const double & l,
const double & alpha = 0.5,
const double & lambda = 0.5,
int octaves = 8,
const Vector & t = Vector::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

◆ Gradient()

Vector SimplexTurbulence3D::Gradient ( const Vector & p) const
virtual

Computes the gradient of the turbulence at a given point, analytically.

The gradient of the sum of the octaves is the sum of the gradients of the simplex noise, see SimplexNoise3D::Gradient(), scaled by the amplitude and by the inverse of the wavelength of the octave, and rotated back by the inverse of the rotation applied to the point in the octave.

Parameters
pPoint.
See also
Value()

Reimplemented from SimplexNoise3D.

◆ K()

double SimplexTurbulence3D::K ( ) const
virtual

Return the global Lipschitz constant.

See also
SimplexNoise3D::K()

Reimplemented from SimplexNoise3D.

◆ UnitAt()

double SimplexTurbulence3D::UnitAt ( const Vector & p) const
protected

Computes the 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.

◆ UnitGradientAt()

Vector SimplexTurbulence3D::UnitGradientAt ( const Vector & p) const
protected

Computes the gradient of the unit turbulence at a given point.

The octave i uses the point rotated by \( R^i \), divided by the wavelength \( \lambda^i \) and has the amplitude \( \alpha^i \): its contribution to the gradient is \( (\alpha/\lambda)^i \, (R^i)^t \nabla n(R^i q / \lambda^i) \).

Parameters
pPoint, already divided by the base wavelength.

◆ Value()

double SimplexTurbulence3D::Value ( const Vector & p) const
virtual

Computes the turbulence value at a given point.

Sums a series of scaled simplex noise functions.

Parameters
pPoint.

Reimplemented from SimplexNoise3D.

◆ operator<<

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

Overloaded.

Parameters
sStream.
noiseThe noise.