49 distCfMode_ = _distCfMode;
50 distRelFuncIdx_ = _distRelFuncIdx;
56 distLinkedFuncIdx_.resize(1, _distRelFuncIdx[0]);
57 distEvalCache_.resize(funcCtrlPt_[_distRelFuncIdx[0]].size(), 0);
60 distLinkedArcIdx_ = func2Arc_[_distRelFuncIdx[0]];
63 distLinkedFuncIdx_.resize(1, _distRelFuncIdx[0]);
64 distEvalCache_.resize(funcCtrlPt_[_distRelFuncIdx[0]].size(), 0);
67 distLinkedArcIdx_ = func2Arc_[_distRelFuncIdx[0]];
92 const size_t ctrlPtSize =
funcCtrlPt_[func0Idx].size() - 1;
94 for (
size_t funcCtrlPtIdx = 0; funcCtrlPtIdx < ctrlPtSize; ++funcCtrlPtIdx)
134 _tLattice.reserve(iEnd + 2);
135 const int idxBeforeStart =
static_cast<int>(
computeS() / _ds);
139 for (
size_t i = idxBeforeStart + 1; i < iEnd; ++i)
142 _tLattice.emplace_back(
154 const size_t slSize = _sLattice.size();
156 _tLattice.reserve(_sLattice.size());
180 const size_t cacheCtrlPtIdxRestore = arcIdx;
185 arcIdx = cacheCtrlPtIdxRestore;
197 switch (_evalArcGuarantee)
199 case eag::AFTER_LAST:
202 if (++arcCacheIdx >= ctrlPtSize)
218 case eag::BEFORE_LAST:
221 if (arcCacheIdx == 0)
247 const double dtAbs = fabs(_dt);
248 if (dtAbs < 10 * FLT_MIN)
252 const double vAbs = fabs(_v0);
253 if (fabs(_av) < 10 * FLT_MIN)
257 const double v1 = _v0 + _av * dtAbs;
260 return fabs(_v0 + v1) * _dt / 2.;
269 double dt1 = -_v0 / _av;
270 return retSign * (vAbs * dt1 + fabs(v1) * (dtAbs - dt1)) / 2.;
275 double v0 = _v0, av = _av;
281 if (fabs(av) < 10 * FLT_MIN)
291 const double v0v0 = v0 * v0;
293 double delta = v0v0 + 2. * av * fabs(_ds);
296 return retSign * (+v0 + sqrt(-delta)) / av;
300 return retSign * (+v0 - sqrt(delta)) / av;
TraveledDistCfMode distCfMode_
Closed form distance computation mode.
TraveledDistCfMode
Required type of traveled distance computation relative to the parametric function.
void setDistCfMode(TraveledDistCfMode _distCfMode, const std::vector< std::size_t > &_distRelFuncIdx) override
control point arc parameter
previous evaluation arc <= this evaluation arc
std::vector< std::size_t > distLinkedFuncIdx_
Indexes of parametric functions used for computing the traveled distance.
this evaluation arc is at the arc parametrization begin
TNumType funcsArcEnd_
Arc parametrization at the end of the functions domain definitions (common for all functions)...
virtual void initImpl() override
Called at end of init. To be used by extended classes.
Helper function needed to upgrade c++ 2011.
double computeS() const override
std::vector< std::vector< FuncCtrlPt > > funcCtrlPt_
Stores the control points for all the parametrized functions.
std::vector< double > distEvalCache_
Cached values of traveled distance computation.
ParamFuncsDist & operator=(const ParamFuncsDist &_other)=default
std::size_t distLinkedArcIdx_
Index of the parametrized function that relates to distance computation.
ComputeDs2DtPtr computeDs2DtPtr_
TNumType funcsArcBegin_
Arc parametrization at the beginning of the functions domain definitions (common for all functions)...
double computeT(const double &_s, const EvalArcGuarantee &_evalArcGuarantee=EvalArcGuarantee::NONE) override
ComputeSFuncPtr computeSFuncPtr_
double computeS_AV() const
Computes distance on a piecewise linear function describing the center linear acceleration.
double computeT_V(const double &_ds) const
Computes arc parametrization on a piecewise linear function describing the center linear velocity at ...
std::vector< std::size_t > func2Arc_
Maps the parametrized functions to their afferent arc parametrizations.
ParamFuncsSpline0Dist & operator=(const ParamFuncsSpline0Dist &)
EvalArcGuarantee
Flags if any guarantees about evaluation arc relative to last evaluation arc are present.
agent base center linear velocity is parametric function
virtual double computeFuncInt1(const std::size_t &_funcIdx) const override
Computes integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
agent base center linear acceleration is parametric function
Structure referencing a control point and storing cached relevant function evaluation data (derivativ...
ParamFuncsSpline0Dist::TraveledDistCfMode TDM
double & ctrlPtVal(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim=CtrlPtDim::VAL)
Access of a parametric function control point dimension.
std::vector< std::vector< FuncCacheData > > funcEvalCache_
Cached values of the used function evaluation modes.
void setEvalArc(const double &_funcsArcEval, const EvalArcGuarantee &_evalArcGuarantee=EvalArcGuarantee::NONE) override
Sets parametric function evaluation arc.
TNumType funcsArcEval_
Arc parametrization at the evaluation point (set by setEvalArc)/.
static double computeDeltaT_V_AV(const double &_ds, const double &_v0, const double &_av)
Helper function that computes deltaT (from the evalArc_ position) operating on one function control p...
Extends manipulation of parametric functions collection with closed-form arc length (distance) comput...
constexpr int signum(T x, std::false_type is_signed)
std::vector< std::size_t > funcEvalArcCacheIdxUnder_
Contains the index of the <u>next</u> control point relative to the last evaluation point...
no closed-form distance computation mode
void setEvalDist(const double &_funcsDistEval, const EvalArcGuarantee &_evalArcGuarantee=EvalArcGuarantee::NONE) override
Moves to evaluation arc at which the traveled distance _funcsDistEval is achieved.
ParamFuncsSpline0Dist()=default
virtual double computeFuncDiff1(const std::size_t &_funcIdx) const override
Computes 1st derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
virtual double computeFuncVal(const std::size_t &_funcIdx) const override
Computes value of parametric function with index _funcIdx at parametric arc set by setEvalArc...
static double computeDeltaS_V_AV(const double &_dt, const double &_v0, const double &_av)
Helper function that computes deltaS (from the evalArc_ position) operating on one function control p...
void precomputeDist()
Precomputes distance invervals.
double computeS_V() const
Computes distance on a piecewise linear function describing the center linear velocity.
double computeTImpl(const double &_s, const EvalArcGuarantee &_evalArcGuarantee)
Internal implementation of computing the arc parametrization given a distance _s. ...
double computeT_AV(const double &_ds) const
Computes arc parametrization on a piecewise linear function describing the center linear acceleration...
std::vector< std::size_t > distRelFuncIdx_
this evaluation arc is at the arc parametrization begin
this evaluation arc is at the arc parametrization end
void computeS2TLattice(const std::vector< double > &_sLattice, std::vector< double > &_tLattice) override
Computes arc parametrization lattice given a distance-parametrized lattice.