From dc5093f732cabc98ce03556e0f3a697baf921c35 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 9 Nov 2018 02:53:58 +0100 Subject: [PATCH] Ref T429, interpolator functions --- .../simulation/interpolatorfunctions.h | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/blackmisc/simulation/interpolatorfunctions.h diff --git a/src/blackmisc/simulation/interpolatorfunctions.h b/src/blackmisc/simulation/interpolatorfunctions.h new file mode 100644 index 000000000..77a58777a --- /dev/null +++ b/src/blackmisc/simulation/interpolatorfunctions.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_SIMULATION_INTERPOLATORFUNCTIONS_H +#define BLACKMISC_SIMULATION_INTERPOLATORFUNCTIONS_H + +namespace BlackMisc +{ + namespace Simulation + { + //! Valid time fraction [0,1] + inline bool isValidTimeFraction(double timeFraction) + { + return timeFraction >= 0.0 && timeFraction <= 1.0; + } + + //! Clamp time fraction [0,1] + inline double clampValidTimeFraction(double timeFraction) + { + if (timeFraction > 1.0) { return 1.0; } + if (timeFraction < 0.0) { return 0.0; } + return timeFraction; + } + } // namespace +} // namespace +#endif // guard