20 float ratio = currentTime /
period;
39 float wave = (ratio > 0.5f ? 1.0f - ratio : ratio) * 2.0f;
44 float wave = ratio > 0.5f ? 1.0f : 0.0f;
49 float wave =
sinf(ratio * 360.0f * 3.14159f / 180.0f);
58 return (ratio * 2.0f) < 1.0f ? ratio * ratio * 4.0f : 1.0f;
Provides a generator for common mathematical wave functions.
float SquareWave(float ratio)
Generates a square wave value.
void SetPeriod(float period)
Sets the period of the waveform.
float SawtoothWave(float ratio)
Generates a sawtooth wave value.
float minimum
Minimum value of the waveform.
float maximum
Maximum value of the waveform.
Function
Enumerates the supported wave functions.
@ Gravity
Gravity-like function.
@ Sawtooth
Sawtooth waveform.
@ Triangle
Triangle waveform.
FunctionGenerator(Function function, float minimum, float maximum, float period)
Constructor to initialize the FunctionGenerator with parameters.
float GravityFunction(float ratio)
Generates a gravity-like function value.
float Update()
Updates and calculates the next value of the waveform.
Function function
Current waveform function.
float SineWave(float ratio)
Generates a sine wave value.
void SetFunction(Function function)
Sets the waveform function.
float TriangleWave(float ratio)
Generates a triangle wave value.
float period
Period of the waveform.
Implements a generic Kalman Filter for 1D data.
static T Map(T value, T inLow, T inMax, T outMin, T outMax)
Maps a value from one range to another.