diff --git a/modules/autonavigation/pathsegment.cpp b/modules/autonavigation/pathsegment.cpp index 83c6acc4e8..fbf90c3872 100644 --- a/modules/autonavigation/pathsegment.cpp +++ b/modules/autonavigation/pathsegment.cpp @@ -142,7 +142,7 @@ void PathSegment::initCurve() { _start.rotation(), _end.rotation() ); - _speedFunction = std::make_unique(); + _speedFunction = std::make_unique(); break; case CurveType::Bezier3: @@ -154,7 +154,7 @@ void PathSegment::initCurve() { _end.node()->worldPosition(), _curve.get() ); - _speedFunction = std::make_unique(); + _speedFunction = std::make_unique(); break; case CurveType::Linear: @@ -163,7 +163,7 @@ void PathSegment::initCurve() { _start.rotation(), _end.rotation() ); - _speedFunction = std::make_unique(); + _speedFunction = std::make_unique(); break; case CurveType::ZoomOutOverview: @@ -175,7 +175,7 @@ void PathSegment::initCurve() { _end.node()->worldPosition(), _curve.get() ); - _speedFunction = std::make_unique(); + _speedFunction = std::make_unique(); break; default: diff --git a/modules/autonavigation/speedfunction.cpp b/modules/autonavigation/speedfunction.cpp index d0c015acf9..ffb5510a3b 100644 --- a/modules/autonavigation/speedfunction.cpp +++ b/modules/autonavigation/speedfunction.cpp @@ -85,4 +85,30 @@ double SexticDampenedSpeed::value(double t) const { return speed; } +QuinticDampenedSpeed::QuinticDampenedSpeed() { + initIntegratedSum(); +} + +double QuinticDampenedSpeed::value(double t) const { + ghoul_assert(t >= 0.0 && t <= 1.0, "Variable t out of range [0,1]"); + + const double tPeak = 0.5; + double speed = 0.0; + + // accelerate + if (t <= tPeak) { + double tScaled = t / tPeak; + speed = ghoul::cubicEaseInOut(ghoul::quadraticEaseInOut(tScaled)); + } + // deaccelerate + else if (t <= 1.0) { + double tScaled = (t - tPeak) / (1.0 - tPeak); + speed = 1.0 - ghoul::cubicEaseInOut(ghoul::quadraticEaseInOut(tScaled)); + } + + // avoid zero speed + speed += 0.00001; // TODO: Minimal speed should depend on size of visible object/node + return speed; +} + } // namespace openspace::autonavigation diff --git a/modules/autonavigation/speedfunction.h b/modules/autonavigation/speedfunction.h index 88616b5dfc..2e5fe0a8fc 100644 --- a/modules/autonavigation/speedfunction.h +++ b/modules/autonavigation/speedfunction.h @@ -52,6 +52,12 @@ public: double value(double t) const override; }; +class QuinticDampenedSpeed : public SpeedFunction { +public: + QuinticDampenedSpeed(); + double value(double t) const override; +}; + } // namespace openspace::autonavigation #endif // __OPENSPACE_MODULE_AUTONAVIGATION___SPEEDFUNCTION___H__