Yasiu Math 1
Collection of mathematic functions that help create game mechanics and procedural tools
Loading...
Searching...
No Matches
YasiuMath::Ballistics::ProjectileDynamicState< T > Struct Template Reference

Ballistic state. Can move in time with DiscreteStep function. More...

#include <YasiuMathLib.h>

Public Member Functions

ProjectileDynamicState Predict (T QueryTime, T DeltaTime) const
 Prediction.
ProjectileDynamicState PredictQuick (T QueryTime) const
 Quick prediction of ballistic state at time. Limitation: Only constant acceleration and no Air Drag. O(1).
virtual void DiscreteStep (T deltaTime)
 Discrete Step. Function used to modify state in time.
void AutoStep (T QueryTime, T DeltaTime)
 Step function. O(1) for AirDrag=0.

Public Attributes

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.

Detailed Description

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.

Member Function Documentation

◆ AutoStep()

template<typename T>
void YasiuMath::Ballistics::ProjectileDynamicState< T >::AutoStep ( T QueryTime,
T DeltaTime )
inline

Step function. O(1) for AirDrag=0.

Iterative prediction for models with AirDrag > 0 Loop count is N = QueryTime / DeltaTime

Parameters
QueryTimeTime to predict into future
DeltaTimeStep 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()

template<typename T>
virtual void YasiuMath::Ballistics::ProjectileDynamicState< T >::DiscreteStep ( T deltaTime)
inlinevirtual

Discrete Step. Function used to modify state in time.

Parameters
deltaTimeTime 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()

template<typename T>
ProjectileDynamicState YasiuMath::Ballistics::ProjectileDynamicState< T >::Predict ( T QueryTime,
T DeltaTime ) const
inline

Prediction.

Accuracy depends on DeltaTime. Big delta is faster but with bigger numeric error.

Parameters
QueryTimePredict position at this time
DeltaTimeTime for single step, suggested range <0.1, 1>
Returns
New State at query time

◆ PredictQuick()

template<typename T>
ProjectileDynamicState YasiuMath::Ballistics::ProjectileDynamicState< T >::PredictQuick ( T QueryTime) const
inline

Quick prediction of ballistic state at time. Limitation: Only constant acceleration and no Air Drag. O(1).

Parameters
QueryTimeTime To Predict
Returns
Flag tells if projectile has reached full speed or still accelerates
Note
Use Predict for iterative solution when dealing with AirDrag

Member Data Documentation

◆ AirFrictionCoeff

template<typename T>
T YasiuMath::Ballistics::ProjectileDynamicState< T >::AirFrictionCoeff = 0

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: