Core 1.0
SimplexNoiseField2 Class Reference

Random vector field in the plane, obtained from two simplex noises. More...

#include <noise.h>

Inheritance diagram for SimplexNoiseField2:
AnalyticVectorField2

Public Member Functions

 SimplexNoiseField2 ()
 Empty.
 ~SimplexNoiseField2 ()
 Empty.
Vector2 Value (const Vector2 &) const
 Evaluate the random displacement at a point.
Matrix2 Jacobian (const Vector2 &) const
 Compute the Jacobian matrix of the field, analytically.
double Divergence (const Vector2 &) const
 Compute the divergence of the field, analytically.
double Curl (const Vector2 &) const
 Compute the curl of the field, analytically.
double K () const
 Compute the Lipschitz constant of the field.

Static Protected Attributes

static const SimplexNoise2 noise
 Simplex noise, shared by all the fields.
static constexpr Vector2 offset = Vector2(37.2, 91.7)
 Offset between the two components of the field, large and not integer.
Static Protected Attributes inherited from AnalyticVectorField2
static constexpr double epsilon = 1e-6
 Epsilon value for partial derivatives.

Detailed Description

Random vector field in the plane, obtained from two simplex noises.

The class derives from AnalyticVectorField2 and uses a SimplexNoise2 shared by all the fields, stored in a static member. The class cannot derive from SimplexNoise2 too, since the virtual functions Value() of the two bases have the same signature and different return types.

The two components are two evaluations of the same simplex noise at two shifted points, \( V(p)=(n(p),n(p+o)) \), where the offset \( o \) is large and not integer, so that the two components are uncorrelated.

The field is smooth and its components are in the \( [-1,1] \) interval, but the vectors are neither of unit length, nor divergence-free: it is well suited to domain warping, but not to the animation of fluids, for which the curl of a scalar noise should be used instead. The divergence and the curl are computed analytically from the gradient of the noise, see SimplexNoise2::Gradient().

Vector2 q = p + 0.2 * field.Value(p / lambda);
SimplexNoiseField2()
Empty.
Definition noise.h:122
Vector2 Value(const Vector2 &) const
Evaluate the random displacement at a point.
Definition noise-field-simplex.cpp:35
Vectors in two dimensions.
Definition evector.h:632
See also
SimplexNoise2, AnalyticVectorField2

Member Function Documentation

◆ Curl()

double SimplexNoiseField2::Curl ( const Vector2 & p) const
virtual

Compute the curl of the field, analytically.

\( \nabla\times V=\partial_x n(p+o)-\partial_y n(p) \).

Parameters
pPoint.

Reimplemented from AnalyticVectorField2.

◆ Divergence()

double SimplexNoiseField2::Divergence ( const Vector2 & p) const
virtual

Compute the divergence of the field, analytically.

\( \nabla\cdot V=\partial_x n(p)+\partial_y n(p+o) \).

Parameters
pPoint.

Reimplemented from AnalyticVectorField2.

◆ Jacobian()

Matrix2 SimplexNoiseField2::Jacobian ( const Vector2 & p) const

Compute the Jacobian matrix of the field, analytically.

The rows of the matrix are the gradients of the two noises, see SimplexNoise2::Gradient():

\[ J(p)=\begin{pmatrix} \partial_x n(p) & \partial_y n(p) \\ \partial_x n(p+o) & \partial_y n(p+o) \end{pmatrix} \]

so that the divergence and the curl are the trace and the antisymmetric part of the Jacobian matrix. The element (i,j) of the matrix is the partial derivative of the component i with respect to the coordinate j.

Parameters
pPoint.
See also
Divergence(), Curl()

◆ K()

double SimplexNoiseField2::K ( ) const

Compute the Lipschitz constant of the field.

The constant of the noise bounds the norm of its gradient: the norm of the Jacobian matrix of the field, whose rows are the two gradients, is therefore bounded by the constant of the noise times \( \sqrt{2} \). This is the constant of the field itself: for a domain warping \( p+A\,V(p/\lambda) \) the constant is bounded by \( 1+\sqrt{2}\,A\,K/\lambda \).

◆ Value()

Vector2 SimplexNoiseField2::Value ( const Vector2 & p) const
virtual

Evaluate the random displacement at a point.

The first component is the noise evaluated at p, the second one is the noise evaluated at the shifted point p+o.

Parameters
pPoint.

Reimplemented from AnalyticVectorField2.