6 #include "../../libs/vector2/vector2.h"
7 #include "../../GrailData/UtilityModel/CurveTypeId.h"
22 virtual ~
Curve() =
default;
29 virtual float Sample(
float argument)
const = 0;
31 virtual CurveTypeId GetTypeId()
const = 0;
41 template <
typename... ConstructorArguments>
42 LowerBound(
float initLowerBound, ConstructorArguments&&... arguments)
43 : curve{ std::forward<ConstructorArguments>(arguments)... }, lowerBound{ initLowerBound }
47 virtual float Sample(
float argument)
const override
49 float result = curve.Sample(argument);
50 return result < lowerBound ? lowerBound : result;
53 const T& GetCurve()
const
58 float GetLowerBound()
const
63 CurveTypeId GetTypeId()
const override
65 return curve.GetTypeId();
70 float lowerBound = 0.0f;
80 template <
typename... ConstructorArguments>
81 UpperBound(
float initUpperBound, ConstructorArguments&&... arguments)
82 : curve{ std::forward<ConstructorArguments>(arguments)... }, upperBound{ initUpperBound }
86 virtual float Sample(
float argument)
const override
88 float result = curve.Sample(argument);
89 return result > upperBound ? upperBound : result;
92 const T& GetCurve()
const
97 float GetUpperBound()
const
102 CurveTypeId GetTypeId()
const override
104 return curve.GetTypeId();
109 float upperBound = 0.0f;
112 template <
typename T>
113 using BoundedCurve = LowerBound<UpperBound<T>>;
115 std::vector<Vector2> DiscretizeCurve(
const Curve& curve, std::size_t samplesQuantity);
The Curve class - Defines objects transforming one value into the other.
Definition: Curve.hh:17
virtual float Sample(float argument) const =0
Sample - User-defined method which processes provided value (currently vector of values - multidemens...
The LowerBound class - Can hold arbitrary curve, but lowerbounds it to provided value.
Definition: Curve.hh:39
virtual float Sample(float argument) const override
Sample - User-defined method which processes provided value (currently vector of values - multidemens...
Definition: Curve.hh:47
The UpperBound class - Can hold arbitrary curve, but upperbounds it to provided value.
Definition: Curve.hh:78
virtual float Sample(float argument) const override
Sample - User-defined method which processes provided value (currently vector of values - multidemens...
Definition: Curve.hh:86