129 lines
3.4 KiBLFS
C++
129 lines
3.4 KiBLFS
C++
/**
|
|
* @file
|
|
*
|
|
* @author Max Lammers <max@senseglove.com>
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @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 <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "Platform.hpp"
|
|
|
|
namespace SGCore
|
|
{
|
|
namespace Kinematics
|
|
{
|
|
class SGCORE_API InterpolationSet;
|
|
}// namespace Kinematics
|
|
}// namespace SGCore
|
|
|
|
/// <summary> Set of variables to map a value from one range to the next. </summary>
|
|
class SGCORE_API SGCore::Kinematics::InterpolationSet
|
|
{
|
|
public:
|
|
/// <summary> Convert a string notation of an InterpolationSet into a new class instance. </summary>
|
|
/// <param name="serializedString"></param>
|
|
/// <returns></returns>
|
|
static InterpolationSet Deserialize(const std::string& serializedString);
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> Pimpl;
|
|
|
|
public:
|
|
/// <summary> Creates a basic interpolation set, without limits. </summary>
|
|
InterpolationSet();
|
|
|
|
/// <summary> Create a new interpolation set without limits. </summary>
|
|
InterpolationSet(float from1, float from2, float to1, float to2);
|
|
|
|
/// <summary> Create a new interpolation set with limits. </summary>
|
|
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;
|
|
|
|
/// <summary> Basic Destructor. </summary>
|
|
virtual ~InterpolationSet();
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
InterpolationSet& operator=(const InterpolationSet& rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
InterpolationSet& operator=(InterpolationSet&& rhs) noexcept;
|
|
|
|
public:
|
|
/// <summary> First value of input range.</summary>
|
|
[[nodiscard]] float GetX0() const;
|
|
|
|
void SetX0(float x0);
|
|
|
|
/// <summary> Second value of input range. </summary>
|
|
[[nodiscard]] float GetX1() const;
|
|
|
|
void SetX1(float x1);
|
|
|
|
/// <summary> First value of output range. </summary>
|
|
[[nodiscard]] float GetY0() const;
|
|
|
|
void SetY0(float y0);
|
|
|
|
/// <summary> Second value of output range. </summary>
|
|
[[nodiscard]] float GetY1() const;
|
|
|
|
void SetY1(float y1);
|
|
|
|
/// <summary> Minimum range of the output value. </summary>
|
|
[[nodiscard]] float GetMin() const;
|
|
|
|
void SetMin(float min);
|
|
|
|
/// <summary> Maximum range of the output value. </summary>
|
|
[[nodiscard]] float GetMax() const;
|
|
|
|
void SetMax(float max);
|
|
|
|
public:
|
|
/// <summary> Calculate an output value in range [x0...x1] to [y0..y1] </summary>
|
|
[[nodiscard]] float Get(float value, bool bLimit, bool bNormalizeAngle = false) const;
|
|
|
|
public:
|
|
/// <summary> Returns true if this InterpolationSet has the same values as another set. </summary>
|
|
/// <param name="other"></param>
|
|
/// <returns></returns>
|
|
[[nodiscard]] bool Equals(const InterpolationSet& interpolationSet) const;
|
|
|
|
public:
|
|
[[nodiscard]] std::string ToString() const;
|
|
|
|
[[nodiscard]] std::string ToString(bool bLimits) const;
|
|
|
|
/// <summary> Convert this InterpolationSet into a string notation so it can be stored on disk. </summary>
|
|
/// <returns></returns>
|
|
[[nodiscard]] std::string Serialize() const;
|
|
}; |