![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Simulates bouncing physics with gravity and velocity damping. More...
#include <BouncePhysics.h>

Public Member Functions | |
| BouncePhysics (float gravity, float velocityRatio=1.0f) | |
| Constructs a BouncePhysics object with the specified gravity and velocity ratio. | |
| float | Calculate (float velocity, unsigned long currentMillis) |
| Calculates the new position and velocity based on the current velocity and time. | |
| float | Calculate (float velocity, float dT) |
| Calculates the new position and velocity based on the current velocity and time delta. | |
Private Attributes | |
| RunningAverageFilter< 10 > | velocityFilter |
| Filter to smooth out velocity fluctuations. | |
| float | currentVelocity |
| Current velocity of the object. | |
| float | currentPosition |
| Current position of the object. | |
| float | velocityRatio |
| Ratio to control velocity damping. | |
| float | gravity |
| Gravity constant affecting the motion. | |
| unsigned long | previousMillis |
| Stores the last timestamp for time-based calculations. | |
| float | previousVelocity |
| Tracks the velocity from the previous update. | |
Simulates bouncing physics with gravity and velocity damping.
Definition at line 22 of file BouncePhysics.h.
| BouncePhysics | ( | float | gravity, |
| float | velocityRatio = 1.0f |
||
| ) |
Constructs a BouncePhysics object with the specified gravity and velocity ratio.
| gravity | Gravitational acceleration affecting the bounce. |
| velocityRatio | Damping ratio for the velocity (default is 1.0). |
Definition at line 3 of file BouncePhysics.cpp.
Calculates the new position and velocity based on the current velocity and time delta.
| velocity | Initial velocity to calculate the bounce. |
| dT | Time delta in seconds. |
Definition at line 26 of file BouncePhysics.cpp.
References currentPosition, currentVelocity, RunningAverageFilter< memory >::Filter(), gravity, previousVelocity, velocityFilter, and velocityRatio.
Calculates the new position and velocity based on the current velocity and time.
| velocity | Initial velocity to calculate the bounce. |
| currentMillis | Current time in milliseconds. |
Definition at line 13 of file BouncePhysics.cpp.
References currentPosition, currentVelocity, gravity, previousMillis, and velocityRatio.
Referenced by AudioReactiveGradient::Update(), and SpectrumAnalyzer::Update().
|
private |
Current position of the object.
Definition at line 26 of file BouncePhysics.h.
Referenced by Calculate(), and Calculate().
|
private |
Current velocity of the object.
Definition at line 25 of file BouncePhysics.h.
Referenced by Calculate(), and Calculate().
|
private |
Gravity constant affecting the motion.
Definition at line 28 of file BouncePhysics.h.
Referenced by Calculate(), and Calculate().
Stores the last timestamp for time-based calculations.
Definition at line 29 of file BouncePhysics.h.
Referenced by Calculate().
|
private |
Tracks the velocity from the previous update.
Definition at line 30 of file BouncePhysics.h.
Referenced by Calculate().
|
private |
Filter to smooth out velocity fluctuations.
Definition at line 24 of file BouncePhysics.h.
Referenced by Calculate().
|
private |
Ratio to control velocity damping.
Definition at line 27 of file BouncePhysics.h.
Referenced by Calculate(), and Calculate().