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

Smooths transitions between values using a linear ramp approach. More...

#include <RampFilter.h>

Public Member Functions

 RampFilter ()
 Default constructor for RampFilter.
 
 RampFilter (int frames, float epsilon=0.01f)
 Constructs a RampFilter with a specified transition duration and epsilon.
 
float Filter (float value)
 Applies the ramp filter to the specified target value.
 
void SetIncrement (float increment)
 Sets the increment for each transition step.
 
void SetFrames (int frames)
 Sets the number of frames for a complete transition.
 

Private Attributes

float increment
 The step size for each frame of the transition.
 
float filter
 The current filtered value.
 
float epsilon
 A small tolerance to determine when to stop adjusting.
 

Detailed Description

Smooths transitions between values using a linear ramp approach.

This class incrementally adjusts an internal filter value towards a target, ensuring smooth transitions.

Definition at line 24 of file RampFilter.h.

Constructor & Destructor Documentation

◆ RampFilter() [1/2]

Default constructor for RampFilter.

Initializes the filter with default parameters.

Definition at line 3 of file RampFilter.cpp.

References epsilon, filter, and increment.

◆ RampFilter() [2/2]

RampFilter ( int  frames,
float  epsilon = 0.01f 
)

Constructs a RampFilter with a specified transition duration and epsilon.

Parameters
framesThe number of frames for a complete transition.
epsilonThe tolerance for considering the transition complete.

Definition at line 9 of file RampFilter.cpp.

References epsilon, and increment.

Member Function Documentation

◆ Filter()

float Filter ( float  value)

Applies the ramp filter to the specified target value.

Smoothly transitions the internal filter value towards the given target.

Parameters
valueThe target value to filter towards.
Returns
The filtered value.

Definition at line 14 of file RampFilter.cpp.

References epsilon, filter, increment, and Mathematics::IsClose().

◆ SetFrames()

void SetFrames ( int  frames)

Sets the number of frames for a complete transition.

Automatically calculates the increment based on the number of frames.

Parameters
framesThe number of frames for a complete transition.

Definition at line 30 of file RampFilter.cpp.

References increment.

◆ SetIncrement()

void SetIncrement ( float  increment)

Sets the increment for each transition step.

Parameters
incrementThe step size for each frame of the transition.

Definition at line 26 of file RampFilter.cpp.

References increment.

Member Data Documentation

◆ epsilon

float epsilon
private

A small tolerance to determine when to stop adjusting.

Definition at line 28 of file RampFilter.h.

Referenced by Filter(), RampFilter(), and RampFilter().

◆ filter

float filter
private

The current filtered value.

Definition at line 27 of file RampFilter.h.

Referenced by Filter(), and RampFilter().

◆ increment

float increment
private

The step size for each frame of the transition.

Definition at line 26 of file RampFilter.h.

Referenced by Filter(), RampFilter(), RampFilter(), SetFrames(), and SetIncrement().


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