1 #ifndef GRAIL_POWER_FUNCTION_H 
    2 #define GRAIL_POWER_FUNCTION_H 
   11         template <
typename ContextType>
 
   30                 : 
Curve<ContextType>{childEvaluator}, slope(slope), intercept(intercept), exponent(exponent)
 
   42                           std::pair<float, float> firstPoint,
 
   43                           std::pair<float, float> secondPoint,
 
   45                 : 
Curve<ContextType>{childEvaluator}, exponent{exponent}
 
   47                 if(firstPoint.first > secondPoint.first)
 
   49                     float x = firstPoint.first;
 
   50                     float y = firstPoint.second;
 
   51                     firstPoint.first = secondPoint.first;
 
   52                     firstPoint.second = secondPoint.second;
 
   53                     secondPoint.first = x;
 
   54                     secondPoint.second = y;
 
   56                 slope = (std::pow(secondPoint.second, 1 / exponent) - std::pow(firstPoint.second, 1 / exponent)) / (
 
   57                             secondPoint.first - firstPoint.first);
 
   58                 intercept = std::pow(firstPoint.second, 1 / exponent) - (slope * firstPoint.first);
 
   61             virtual float Sample(
float argument) 
const override final 
   63                 float linearPart = slope * argument + intercept;
 
   66                     int intExponent = 
static_cast<int>(exponent);
 
   67                     if(exponent - intExponent > 0.0f)
 
   73                 return std::pow(linearPart, exponent);
 
   92             virtual EvaluatorType GetEvaluatorType() const override final { 
return EvaluatorType::CURVE_POWER; }
 
   96             float intercept = 0.0f;
 
   97             float exponent = 0.0f;
 
  102 #endif // GRAIL_POWER_FUNCTION_H