mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
32 lines
946 B
C++
32 lines
946 B
C++
// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
|
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
|
|
|
//! \file
|
|
|
|
#ifndef BLACKMISC_SIMULATION_INTERPOLATORFUNCTIONS_H
|
|
#define BLACKMISC_SIMULATION_INTERPOLATORFUNCTIONS_H
|
|
|
|
namespace BlackMisc::Simulation
|
|
{
|
|
//! Valid time fraction [0,1]
|
|
inline bool isValidTimeFraction(double timeFraction)
|
|
{
|
|
return timeFraction >= 0.0 && timeFraction <= 1.0;
|
|
}
|
|
|
|
//! Valid time fraction [0,1], this allows minor overshooting
|
|
inline bool isAcceptableTimeFraction(double timeFraction)
|
|
{
|
|
return timeFraction >= 0.0 && timeFraction <= 1.01;
|
|
}
|
|
|
|
//! 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
|
|
#endif // guard
|