EBGeometry  1.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PerlinSDF< T > Class Template Reference

Ken Perlins gradient noise function. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Inheritance diagram for PerlinSDF< T >:
Inheritance graph
[legend]
Collaboration diagram for PerlinSDF< T >:
Collaboration graph
[legend]

Public Member Functions

 PerlinSDF (const T a_noiseAmplitude, const Vec3T< T > a_noiseFrequency, const T a_noisePersistence, const unsigned int a_noiseOctaves) noexcept
 Full constructor. More...
 
virtual ~PerlinSDF () noexcept
 Destructor (does nothing)
 
virtual T signedDistance (const Vec3T< T > &a_point) const noexcept override
 Signed distance function. Generates a distance on [0,curAmplitude]. More...
 
template<class URNG >
void shuffle (URNG &g) noexcept
 Shuffle the permutation with the input RNG. More...
 
std::array< int, 512 > & getPermutationTable () noexcept
 Get the internal permutation table. More...
 
- Public Member Functions inherited from SignedDistanceFunction< T >
 SignedDistanceFunction ()=default
 Disallowed, use the full constructor.
 
virtual ~SignedDistanceFunction ()=default
 Destructor (does nothing)
 
virtual T value (const Vec3T< T > &a_point) const noexcept override final
 Implementation of ImplicitFunction::value. More...
 
virtual Vec3T< T > normal (const Vec3T< T > &a_point, const T &a_delta) const noexcept
 Signed distance normal vector. More...
 
- Public Member Functions inherited from ImplicitFunction< T >
 ImplicitFunction ()=default
 Disallowed, use the full constructor.
 
virtual ~ImplicitFunction ()=default
 Destructor (does nothing)
 
operator() (const Vec3T< T > &a_point) const noexcept
 Alternative signature for the value function. More...
 
template<class BV >
BV approximateBoundingVolumeOctree (const Vec3T< T > &a_initialLowCorner, const Vec3T< T > &a_initialHighCorner, const unsigned int a_maxTreeDepth, const T &a_safety=0.0) const noexcept
 Compute an approximation to the bounding volume for the implicit surface, using octrees. More...
 

Protected Member Functions

virtual T lerp (const T t, const T a, const T b) const noexcept
 Ken Perlin's lerp function. More...
 
virtual T fade (const T t) const noexcept
 Ken Perlin's fade function. More...
 
grad (const int hash, const T x, const T y, const T z) const noexcept
 Ken Perlins grad function. More...
 
noise (const Vec3T< T > &a_point) const noexcept
 Octave noise function. More...
 

Protected Attributes

Vec3T< T > m_noiseFrequency
 Noise frequency.
 
m_noiseAmplitude
 Noise amplitude.
 
m_noisePersistence
 Noise persistence.
 
std::array< T, 512 > m_permutationTable
 Permutation table.
 
unsigned int m_noiseOctaves
 Number of noise octaves.
 

Detailed Description

template<class T>
class PerlinSDF< T >

Ken Perlins gradient noise function.

Constructor & Destructor Documentation

◆ PerlinSDF()

template<class T >
PerlinSDF< T >::PerlinSDF ( const T  a_noiseAmplitude,
const Vec3T< T >  a_noiseFrequency,
const T  a_noisePersistence,
const unsigned int  a_noiseOctaves 
)
inlinenoexcept

Full constructor.

Parameters
[in]a_noiseAmplitudeNoise amplitude
[in]a_noiseFrequencySpatial noise frequency along the three Cartesian axes
[in]a_noisePersistenceNoise amplitude drop-off and frequency increase for octave noise. Should be < 1
[in]a_noiseOctavesNumber of octaves. Should be > 0

Member Function Documentation

◆ fade()

template<class T >
virtual T PerlinSDF< T >::fade ( const T  t) const
inlineprotectedvirtualnoexcept

Ken Perlin's fade function.

Parameters
[in]tInput parameter

◆ getPermutationTable()

template<class T >
std::array<int, 512>& PerlinSDF< T >::getPermutationTable ( )
inlinenoexcept

Get the internal permutation table.

Returns
m_permutationTable.

◆ grad()

template<class T >
T PerlinSDF< T >::grad ( const int  hash,
const T  x,
const T  y,
const T  z 
) const
inlineprotectednoexcept

Ken Perlins grad function.

Parameters
[in]hashInput parameter
[in]xInput parameter
[in]yInput parameter
[in]zInput parameter

◆ lerp()

template<class T >
virtual T PerlinSDF< T >::lerp ( const T  t,
const T  a,
const T  b 
) const
inlineprotectedvirtualnoexcept

Ken Perlin's lerp function.

Parameters
[in]tInput parameter
[in]aInput parameter
[in]bInput parameter

◆ noise()

template<class T >
T PerlinSDF< T >::noise ( const Vec3T< T > &  a_point) const
inlineprotectednoexcept

Octave noise function.

Parameters
[in]a_pointInput point

◆ shuffle()

template<class T >
template<class URNG >
void PerlinSDF< T >::shuffle ( URNG &  g)
inlinenoexcept

Shuffle the permutation with the input RNG.

URNG should be a uniform random number generator, e.g.

Parameters
[in]gUniform random number generator (e.g., std::mt19937)
Note
When using parallel calculations it is exceptionally important that the input RNG is the same across all threads/ranks. Otherwise, the user must manually ensure that the permutation table is the same. Failure to do so implies that each thread/rank generates it's own gradient noise and there is correspondingly no single geometry.

◆ signedDistance()

template<class T >
virtual T PerlinSDF< T >::signedDistance ( const Vec3T< T > &  a_point) const
inlineoverridevirtualnoexcept

Signed distance function. Generates a distance on [0,curAmplitude].

Parameters
[in]a_pointInput point

Implements SignedDistanceFunction< T >.


The documentation for this class was generated from the following file: