|
Core 1.0
|
Random vector field in the plane, obtained from two simplex noises. More...
#include <noise.h>
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. | |
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().
|
virtual |
Compute the curl of the field, analytically.
\( \nabla\times V=\partial_x n(p+o)-\partial_y n(p) \).
| p | Point. |
Reimplemented from AnalyticVectorField2.
|
virtual |
Compute the divergence of the field, analytically.
\( \nabla\cdot V=\partial_x n(p)+\partial_y n(p+o) \).
| p | Point. |
Reimplemented from AnalyticVectorField2.
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.
| p | Point. |
| 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 \).
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.
| p | Point. |
Reimplemented from AnalyticVectorField2.