7 velocityRatio(velocityRatio),
10 previousVelocity(0.0f) {
16 if (dT > 0.1f && dT < 2.0f) {
30 changeRate = changeRate < 0.0f ? 0.0f : changeRate;
Defines the BouncePhysics class for simulating basic bouncing physics with velocity and gravity.
float velocityRatio
Ratio to control velocity damping.
float currentVelocity
Current velocity of the object.
float Calculate(float velocity, unsigned long currentMillis)
Calculates the new position and velocity based on the current velocity and time.
RunningAverageFilter< 10 > velocityFilter
Filter to smooth out velocity fluctuations.
float gravity
Gravity constant affecting the motion.
BouncePhysics(float gravity, float velocityRatio=1.0f)
Constructs a BouncePhysics object with the specified gravity and velocity ratio.
float currentPosition
Current position of the object.
unsigned long previousMillis
Stores the last timestamp for time-based calculations.
float previousVelocity
Tracks the velocity from the previous update.
float Filter(float value)
Filters the input value using the running average.