HighMap library (C++)
Loading...
Searching...
No Matches
hmap::GenericFractalFunction< BaseFn > Class Template Reference

A class for generating fractal noise functions based on an underlying noise function. More...

#include <functions.hpp>

Inheritance diagram for hmap::GenericFractalFunction< BaseFn >:
Collaboration diagram for hmap::GenericFractalFunction< BaseFn >:

Public Member Functions

 GenericFractalFunction (BaseFn base, int octaves, float weight, float persistence, float lacunarity)
 Construct a new GenericFractalFunction object.
void set_kw (glm::vec2 new_kw)
 Set the frequency scaling vector.
void set_lacunarity (float new_lacunarity)
 Set the lacunarity of the fractal noise.
void set_octaves (int new_octaves)
 Set the number of octaves in the fractal noise.
void set_persistence (float new_persistence)
 Set the persistence of the fractal noise.
void set_seed (std::uint32_t new_seed)
 Set a new random seed for the noise generation.
void scale_amp0 (float scale)
 Scale the initial amplitude of the fractal noise.
void set_stretch (float new_angle, float new_stretch, float new_stretch_decay=0.f)
 Configure directional stretching for the fractal noise.
float get_lacunarity () const
 Get the lacunarity of the fractal noise.
int get_octaves () const
 Get the number of octaves in the fractal noise.
float get_persistence () const
 Get the persistence of the fractal noise.
float get_weight () const
 Get the weight of the fractal noise.
Public Member Functions inherited from hmap::NoiseFunction
 NoiseFunction ()
 Default constructor. Initializes with default frequency scaling and seed.
 NoiseFunction (glm::vec2 kw)
 Constructor to initialize with specific frequency scaling.
 NoiseFunction (glm::vec2 kw, std::uint32_t seed)
 Constructor to initialize with specific frequency scaling and seed.
glm::vec2 get_kw () const
 Get the frequency scaling vector.
std::uint32_t get_seed () const
 Get the random seed.
void set_seed (std::uint32_t new_seed)
 Set a new random seed for noise generation.
void set_kw (glm::vec2 new_kw)
 Set a new frequency scaling vector.

Protected Member Functions

void update_amp0 ()
 Update the initial amplitude (amp0) based on the current octaves and persistence.
void apply_stretch (float &x, float &y, int octave) const
 Apply directional stretching to coordinates for a given octave.

Protected Attributes

BaseFn base
 Unique pointer to the base noise function.
int octaves
 Number of octaves in the fractal noise.
float weight
 Weight of the base noise function.
float persistence
 Persistence of the fractal noise.
float lacunarity
 Lacunarity of the fractal noise.
float amp0
 Initial amplitude of the fractal noise.
float angle = 0.f
 Direction angle in degrees.
float stretch = 1.f
 Stretching factor along the direction.
float stretch_decay = 0.f
 Stretching decay across octaves.
float cos_a = 1.f
 Cosine of direction angle.
float sin_a = 0.f
 Sine of direction angle.
Protected Attributes inherited from hmap::NoiseFunction
glm::vec2 kw
 Frequency scaling vector.
std::uint32_t seed
 Random seed for noise generation.

Detailed Description

template<typename BaseFn>
class hmap::GenericFractalFunction< BaseFn >

A class for generating fractal noise functions based on an underlying noise function.

The GenericFractalFunction class generates fractal noise using an underlying base noise function. It allows customization of the fractal properties such as octaves, weight, persistence, and lacunarity.

Constructor & Destructor Documentation

◆ GenericFractalFunction()

template<typename BaseFn>
hmap::GenericFractalFunction< BaseFn >::GenericFractalFunction ( BaseFn base,
int octaves,
float weight,
float persistence,
float lacunarity )
explicit

Construct a new GenericFractalFunction object.

Parameters
p_baseUnique pointer to the base noise function.
octavesNumber of octaves in the fractal noise.
weightWeight of the base noise function.
persistencePersistence of the fractal noise.
lacunarityLacunarity of the fractal noise.

Member Function Documentation

◆ set_kw()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::set_kw ( glm::vec2 new_kw)
inline

Set the frequency scaling vector.

Parameters
new_kwThe new frequency scaling vector.

◆ set_lacunarity()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::set_lacunarity ( float new_lacunarity)
inline

Set the lacunarity of the fractal noise.

Parameters
new_lacunarityThe new lacunarity value.

◆ set_octaves()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::set_octaves ( int new_octaves)
inline

Set the number of octaves in the fractal noise.

Parameters
new_octavesThe new number of octaves.

◆ set_persistence()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::set_persistence ( float new_persistence)
inline

Set the persistence of the fractal noise.

Parameters
new_persistenceThe new persistence value.

◆ set_seed()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::set_seed ( std::uint32_t new_seed)
inline

Set a new random seed for the noise generation.

Parameters
new_seedThe new random seed.

◆ scale_amp0()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::scale_amp0 ( float scale)
inline

Scale the initial amplitude of the fractal noise.

Parameters
scaleThe scale factor for the initial amplitude.

◆ set_stretch()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::set_stretch ( float new_angle,
float new_stretch,
float new_stretch_decay = 0.f )
inline

Configure directional stretching for the fractal noise.

Parameters
new_angleDirection angle in degrees.
new_stretchStretching factor along the direction.
new_stretch_decayProgressive decay of stretching across octaves.

◆ get_lacunarity()

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::get_lacunarity ( ) const
inline

Get the lacunarity of the fractal noise.

Returns
The current lacunarity value.

◆ get_octaves()

template<typename BaseFn>
int hmap::GenericFractalFunction< BaseFn >::get_octaves ( ) const
inline

Get the number of octaves in the fractal noise.

Returns
The current number of octaves.

◆ get_persistence()

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::get_persistence ( ) const
inline

Get the persistence of the fractal noise.

Returns
The current persistence value.

◆ get_weight()

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::get_weight ( ) const
inline

Get the weight of the fractal noise.

Returns
The current weight value.

◆ update_amp0()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::update_amp0 ( )
protected

Update the initial amplitude (amp0) based on the current octaves and persistence.

◆ apply_stretch()

template<typename BaseFn>
void hmap::GenericFractalFunction< BaseFn >::apply_stretch ( float & x,
float & y,
int octave ) const
inlineprotected

Apply directional stretching to coordinates for a given octave.

Member Data Documentation

◆ base

template<typename BaseFn>
BaseFn hmap::GenericFractalFunction< BaseFn >::base
protected

Unique pointer to the base noise function.

◆ octaves

template<typename BaseFn>
int hmap::GenericFractalFunction< BaseFn >::octaves
protected

Number of octaves in the fractal noise.

◆ weight

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::weight
protected

Weight of the base noise function.

◆ persistence

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::persistence
protected

Persistence of the fractal noise.

◆ lacunarity

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::lacunarity
protected

Lacunarity of the fractal noise.

◆ amp0

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::amp0
protected

Initial amplitude of the fractal noise.

◆ angle

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::angle = 0.f
protected

Direction angle in degrees.

◆ stretch

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::stretch = 1.f
protected

Stretching factor along the direction.

◆ stretch_decay

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::stretch_decay = 0.f
protected

Stretching decay across octaves.

◆ cos_a

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::cos_a = 1.f
protected

Cosine of direction angle.

◆ sin_a

template<typename BaseFn>
float hmap::GenericFractalFunction< BaseFn >::sin_a = 0.f
protected

Sine of direction angle.


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