ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
FunctionGenerator Class Reference

A class to generate various waveform functions with customizable parameters. More...

#include <FunctionGenerator.h>

Public Types

enum  Function {
  Triangle , Square , Sine , Sawtooth ,
  Gravity
}
 Enumerates the supported wave functions. More...
 

Public Member Functions

 FunctionGenerator (Function function, float minimum, float maximum, float period)
 Constructor to initialize the FunctionGenerator with parameters.
 
void SetPeriod (float period)
 Sets the period of the waveform.
 
void SetFunction (Function function)
 Sets the waveform function.
 
float Update ()
 Updates and calculates the next value of the waveform.
 

Private Member Functions

float TriangleWave (float ratio)
 Generates a triangle wave value.
 
float SquareWave (float ratio)
 Generates a square wave value.
 
float SineWave (float ratio)
 Generates a sine wave value.
 
float SawtoothWave (float ratio)
 Generates a sawtooth wave value.
 
float GravityFunction (float ratio)
 Generates a gravity-like function value.
 

Private Attributes

Function function
 Current waveform function.
 
float minimum = 0.0f
 Minimum value of the waveform.
 
float maximum = 0.0f
 Maximum value of the waveform.
 
float period = 0.0f
 Period of the waveform.
 

Detailed Description

A class to generate various waveform functions with customizable parameters.

Definition at line 19 of file FunctionGenerator.h.

Member Enumeration Documentation

◆ Function

Enumerates the supported wave functions.

Enumerator
Triangle 

Triangle waveform.

Square 

Square waveform.

Sine 

Sine waveform.

Sawtooth 

Sawtooth waveform.

Gravity 

Gravity-like function.

Definition at line 25 of file FunctionGenerator.h.

Constructor & Destructor Documentation

◆ FunctionGenerator()

FunctionGenerator ( Function  function,
float  minimum,
float  maximum,
float  period 
)

Constructor to initialize the FunctionGenerator with parameters.

Parameters
functionThe waveform function to use.
minimumThe minimum value of the waveform.
maximumThe maximum value of the waveform.
periodThe period of the waveform.

Definition at line 3 of file FunctionGenerator.cpp.

References function, maximum, minimum, and period.

Member Function Documentation

◆ GravityFunction()

float GravityFunction ( float  ratio)
private

Generates a gravity-like function value.

Parameters
ratioThe input ratio (0 to 1).
Returns
The output wave value.

Definition at line 57 of file FunctionGenerator.cpp.

Referenced by Update().

◆ SawtoothWave()

float SawtoothWave ( float  ratio)
private

Generates a sawtooth wave value.

Parameters
ratioThe input ratio (0 to 1).
Returns
The output wave value.

Definition at line 53 of file FunctionGenerator.cpp.

References Mathematics::Map(), maximum, and minimum.

Referenced by Update().

◆ SetFunction()

void SetFunction ( Function  function)

Sets the waveform function.

Parameters
functionThe new waveform function.

Definition at line 14 of file FunctionGenerator.cpp.

References function.

◆ SetPeriod()

void SetPeriod ( float  period)

Sets the period of the waveform.

Parameters
periodThe new period.

Definition at line 10 of file FunctionGenerator.cpp.

References period.

Referenced by ProtogenProject::SetWiggleSpeed().

◆ SineWave()

float SineWave ( float  ratio)
private

Generates a sine wave value.

Parameters
ratioThe input ratio (0 to 1).
Returns
The output wave value.

Definition at line 48 of file FunctionGenerator.cpp.

References Mathematics::Map(), maximum, and minimum.

Referenced by Update().

◆ SquareWave()

float SquareWave ( float  ratio)
private

Generates a square wave value.

Parameters
ratioThe input ratio (0 to 1).
Returns
The output wave value.

Definition at line 43 of file FunctionGenerator.cpp.

References Mathematics::Map(), maximum, and minimum.

Referenced by Update().

◆ TriangleWave()

float TriangleWave ( float  ratio)
private

Generates a triangle wave value.

Parameters
ratioThe input ratio (0 to 1).
Returns
The output wave value.

Definition at line 38 of file FunctionGenerator.cpp.

References Mathematics::Map(), maximum, and minimum.

Referenced by Update().

◆ Update()

float Update ( )

Updates and calculates the next value of the waveform.

Returns
The calculated wave value.

Definition at line 18 of file FunctionGenerator.cpp.

References function, Gravity, GravityFunction(), period, Sawtooth, SawtoothWave(), Sine, SineWave(), Square, SquareWave(), Triangle, and TriangleWave().

Referenced by Fisheye::ApplyEffect(), PhaseOffsetR::ApplyEffect(), PhaseOffsetX::ApplyEffect(), PhaseOffsetY::ApplyEffect(), RadialBlur::ApplyEffect(), ShiftR::ApplyEffect(), Test::ApplyEffect(), XenraxAnimation::Battery(), ProtogenProject::GetWiggleOffset(), XenraxAnimation::Hearts(), XenraxAnimation::Hypno(), DrGonzoProject::Loading(), SergaliciousAnimation::Loading(), DrGonzoProject::Sad(), Warzone2Animation::Sleep(), XenraxAnimation::Sleeping(), AlphaAnimation::SpyroDisplay(), SageAnimation::Tired(), Boot::Update(), FlowNoise::Update(), RainbowNoise::Update(), RainbowNoise2::Update(), RainbowSpiral::Update(), TVStatic::Update(), AphoriAnimation::Update(), ArtleckAnimationV2::Update(), BasilGardenAnimation::Update(), BroookAnimation::Update(), WaffleDaProtoAnimation::Update(), ElGatoAnimation::Update(), GalaxyAnimation::Update(), HertzzAnimation::Update(), InfraredAnimation::Update(), LeonHuskyAnimation::Update(), MyntAnimation::Update(), ProtobottAnimation::Update(), SammyAnimation::Update(), SergaliciousAnimation::Update(), StrawberryAnimation::Update(), TamamoAnimation::Update(), TechSaneAnimation::Update(), VesperAnimation::Update(), WarzoneAnimation::Update(), Warzone2Animation::Update(), XenraxAnimation::Update(), ClockAnimation::Update(), AlphaAnimation::Update(), BetaProject::Update(), GammaAnimation::Update(), HUB75AnimationSplit::Update(), WS35AnimationSplit::Update(), ArtisansAnimation::Update(), BeeAnimation::Update(), CoelaBonkAnimation::Update(), CoelaNerdAnimation::Update(), CreeperAnimation::Update(), CubeAnimation::Update(), FullScreenAnimation::Update(), NukudeFaceAnimation::Update(), PikachuAnimation::Update(), RocksAnimation::Update(), SpyroAnimation::Update(), SpyroRotateAnimation::Update(), VectorFieldAnimation::Update(), and ProtogenProject::UpdateFace().

Member Data Documentation

◆ function

Function function
private

Current waveform function.

Definition at line 34 of file FunctionGenerator.h.

Referenced by FunctionGenerator(), SetFunction(), and Update().

◆ maximum

float maximum = 0.0f
private

Maximum value of the waveform.

Definition at line 36 of file FunctionGenerator.h.

Referenced by FunctionGenerator(), SawtoothWave(), SineWave(), SquareWave(), and TriangleWave().

◆ minimum

float minimum = 0.0f
private

Minimum value of the waveform.

Definition at line 35 of file FunctionGenerator.h.

Referenced by FunctionGenerator(), SawtoothWave(), SineWave(), SquareWave(), and TriangleWave().

◆ period

float period = 0.0f
private

Period of the waveform.

Definition at line 37 of file FunctionGenerator.h.

Referenced by FunctionGenerator(), SetPeriod(), and Update().


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