/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @section LICENSE * * Copyright (c) 2020 - 2022 SenseGlove * * @section DESCRIPTION * * Data class containing all variables to map an input value from one range to another. */ #pragma once #include #include #include #include "Platform.hpp" namespace SGCore { namespace Kinematics { class SGCORE_API InterpolationSet; }// namespace Kinematics }// namespace SGCore /// Set of variables to map a value from one range to the next. class SGCORE_API SGCore::Kinematics::InterpolationSet { public: /// Convert a string notation of an InterpolationSet into a new class instance. /// /// static InterpolationSet Deserialize(const std::string& serializedString); private: struct Impl; std::unique_ptr Pimpl; public: /// Creates a basic interpolation set, without limits. InterpolationSet(); /// Create a new interpolation set without limits. InterpolationSet(float from1, float from2, float to1, float to2); /// Create a new interpolation set with limits. InterpolationSet(float from1, float from2, float to1, float to2, float min, float max); /** * The copy constructor. */ InterpolationSet(const InterpolationSet& rhs); /** * The move constructor. */ InterpolationSet(InterpolationSet&& rhs) noexcept; /// Basic Destructor. virtual ~InterpolationSet(); public: /** * The copy assignment operator. */ InterpolationSet& operator=(const InterpolationSet& rhs); /** * The move assignment operator. */ InterpolationSet& operator=(InterpolationSet&& rhs) noexcept; public: /// First value of input range. [[nodiscard]] float GetX0() const; void SetX0(float x0); /// Second value of input range. [[nodiscard]] float GetX1() const; void SetX1(float x1); /// First value of output range. [[nodiscard]] float GetY0() const; void SetY0(float y0); /// Second value of output range. [[nodiscard]] float GetY1() const; void SetY1(float y1); /// Minimum range of the output value. [[nodiscard]] float GetMin() const; void SetMin(float min); /// Maximum range of the output value. [[nodiscard]] float GetMax() const; void SetMax(float max); public: /// Calculate an output value in range [x0...x1] to [y0..y1] [[nodiscard]] float Get(float value, bool bLimit, bool bNormalizeAngle = false) const; public: /// Returns true if this InterpolationSet has the same values as another set. /// /// [[nodiscard]] bool Equals(const InterpolationSet& interpolationSet) const; public: [[nodiscard]] std::string ToString() const; [[nodiscard]] std::string ToString(bool bLimits) const; /// Convert this InterpolationSet into a string notation so it can be stored on disk. /// [[nodiscard]] std::string Serialize() const; };