template<class TYPE>
class Math::Extrapolator< TYPE >
Extrapolator maintains state about updates for remote entities, and will generate smooth guesses about where those entities will be based on previously received data.
This implementation is based on http://www.mindcontrol.org/~hplus/epic/ Its adapted for use with nebula classes.
You create one Extrapolator per quantity you want to interpolate.
You then feed it updates about where your entity was ("positions") at some point in time. Optionally, you can also give the Extrapolator information about the velocity at that point in time. After that, you can ask the Extrapolator for position values for some given real time. Optionally, you can also ask for the velocity at the same time.
The Extrapolator will assume that an entity stops in place if it hasn't received updates for some time about the entity. It will also keep a running estimate of the latency and frequency of updates.
Extrapolator requires a globally synchronized clock. It does not do any management to deal with clock skew.
- Copyright
- (C) 2006 Jon Watte (C) 2009 Radon Labs GmbH (C) 2013-2025 Individual contributors, see AUTHORS file
|
| Extrapolator () |
| constructor
|
|
| ~Extrapolator ()=default |
| destructor
|
|
bool | AddSample (Timing::Time packetTime, Timing::Time curTime, const TYPE &pos) |
| add sample without velocity, velocity is compute from positions
|
|
bool | AddSample (Timing::Time packetTime, Timing::Time curTime, const TYPE &pos, const TYPE &vel) |
| add sample with given velocity
|
|
void | Reset (Timing::Time packetTime, Timing::Time curTime, const TYPE &pos) |
| Re-set the Extrapolator's idea of time, velocity and position.
|
|
void | Reset (Timing::Time packetTime, Timing::Time curTime, const TYPE &pos, const TYPE &vel) |
| Re-set the Extrapolator's idea of time, velocity and position.
|
|
bool | ReadValue (Timing::Time forTime, TYPE &oPos) const |
| Return an estimate of the interpolated position at a given global time (which typically will be greater than the curTime passed into AddSample()).
|
|
bool | ReadValue (Timing::Time forTime, TYPE &oPos, TYPE &oVel) const |
| Return an estimate of the interpolated position at a given global time (which typically will be greater than the curTime passed into AddSample()).
|
|
Timing::Time | EstimateLatency () const |
|
Timing::Time | EstimateUpdateTime () const |
|
bool | Estimates (Timing::Time packetTime, Timing::Time curTime) |
| is this packet newer than already received
|
|
add sample without velocity, velocity is compute from positions
When you receive data about a remote entity, call AddSample() to tell the Extrapolator about it.
The Extrapolator will throw away a sample with a time that's before any other time it's already gotten, and return false; else it will use the sample to improve its interpolation guess, and return true.
- Parameters
-
packetTime | The globally synchronized time at which the packet was sent (and thus the data valid). |
curTime | The globally synchronized time at which you put the data into the Extrapolator (i e, "now"). |
pos | The position sample valid for packetTime. |
- Returns
- true if packetTime is strictly greater than the previous packetTime, else false.
add sample with given velocity
When you receive data about a remote entity, call AddSample() to tell the Extrapolator about it.
The Extrapolator will throw away a sample with a time that's before any other time it's already gotten, and return false; else it will use the sample to improve its interpolation guess, and return true.
If you get velocity information with your position updates, you can make the guess that Extrapolator makes better, by passing that information along with your position sample.
- Parameters
-
packetTime | The globally synchronized time at which the packet was sent (and thus the data valid). |
curTime | The globally synchronized time at which you put the data into the Extrapolator (i e, "now"). |
pos | The position sample valid for packetTime. |
- Returns
- true if packetTime is strictly greater than the previous packetTime, else false.
- Parameters
-
vel | The velocity of the entity at the time of packetTime. Used to improve the guess about entity position. |