Ballistic state. Can move in time with DiscreteStep function.
More...
#include <YasiuMathLib.h>
|
|
Vec3< T > | Position = 0 |
| | Current position.
|
|
Vec3< T > | Velocity = 0 |
| | Movement velocity vector.
|
|
Vec3< T > | Acceleration = 0 |
| | Acceleration or Deceleration or combined with Gravity Forces.
|
| T | AirFrictionCoeff = 0 |
| | Movement resistance opposite to current velocity vector. Must be in <0, 1> range. More in details...
|
|
T | MaxSpeed = 1000 |
| | Maximal speed(length) of velocity vector.
|
template<typename T>
struct YasiuMath::Ballistics::ProjectileDynamicState< T >
Ballistic state. Can move in time with DiscreteStep function.
Self-sufficient to predict next state with DiscreteStep and AutoStep
- Warning
- AirFrictionCoeff must be within <0, 1> range, otherwise model will not be correct or could crash.
◆ AutoStep()
Step function. O(1) for AirDrag=0.
Iterative prediction for models with AirDrag > 0 Loop count is N = QueryTime / DeltaTime
- Parameters
-
| QueryTime | Time to predict into future |
| DeltaTime | Step size, suggested range <0.1, 1> for stability. |
- Note
- Normally function uses DiscreteStep, but switchest to PredictQuick when AirDrag is 0, effectively being O(1)
-
Last step has very small DeltaTime depending on math error
◆ DiscreteStep()
Discrete Step. Function used to modify state in time.
- Parameters
-
| deltaTime | Time distance to move at single step. |
- Warning
- Using big deltaTime can lead to numeric inaccuracy when dealing with air drag.
-
Keep deltaTime in small range <0.01, 1>. Suggested value 0.1.
◆ Predict()
Prediction.
Accuracy depends on DeltaTime. Big delta is faster but with bigger numeric error.
- Parameters
-
| QueryTime | Predict position at this time |
| DeltaTime | Time for single step, suggested range <0.1, 1> |
- Returns
- New State at query time
◆ PredictQuick()
Quick prediction of ballistic state at time. Limitation: Only constant acceleration and no Air Drag. O(1).
- Parameters
-
- Returns
- Flag tells if projectile has reached full speed or still accelerates
- Note
- Use Predict for iterative solution when dealing with AirDrag
◆ AirFrictionCoeff
Movement resistance opposite to current velocity vector. Must be in <0, 1> range. More in details...
$$Drag = Velocity^2 * Coeff$$
The documentation for this struct was generated from the following file: