# Curve

A curve is a mathematical function transforming one value into another one. Grail’s curves operate on floating point numbers (R→R). They are often used in Grail’s utility evaluators.

A user can inherit from `Curve` class to create their own custom curves or they can make use of Grail’s built-in curve types.

## Basic Curves

Let’s assume that `x` means input value.

### Constant Function

Parameters
• `value`

This function returns `value` disregarding it’s input. ### Step Function

Parameters
• `threshold`

• `beforeThresholdValue`

• `afterThresholdValue`

This function returns `afterThresholdValue` if `x` is greater than `threshold`. Otherwise returns `beforeThresholdValue`. ### Linear Function

Parameters
• `slope`

• `intercept`

This functions returns result of operation `slope` * `x` + `intercept`. ### Power Function

Parameters
• `exponent`

• `slope`

• `intercept`

This function takes linear function and raises it to power determined by `exponent` The result of linear function `slope` * `x` + `intercept` is lowerbound by `0`. ### Exponential Function

Parameters
• `base`

This function raises `base` to `x’th power. ### Sigmoid Function

Parameters
• `slope`

• `threshold`

Work in progress. One day it will become a properly working sigmoid function. ### Linearly Interpolated Curve

Simple linear interpolation applied to a set of points (from R2). ### Bezier Spline

This is a bezier spline created based on a set of waypoints and velocities coming in and out of them. ### Staircase Function

Piecewise constant function with finite amount of pieces. ## Bounded Curves

### Lowerbound

Lowerbound curves cannot return result lesser than their `lowerValue`. • C++

• C#

``auto lowerbound = LowerBound<LinearFunction>{lowerValue, gradient, intercept};``
``````Curve linearCurve = new LinearFunction(gradient, intercept);
LowerBound lowerbound = new LowerBound(linearCurve, lowerValue);``````

### Upperbound

Upperbound curves cannot return result greater than their `upperValue`. • C++

• C#

``auto upperbound = UpperBound<LinearFunction>{upperValue, gradient, intercept};``
``````Curve linearCurve = new LinearFunctiongradient, intercept);
UpperBound upperbound = new UpperBound(linearCurve, upperValue);``````

### Double-Bounded

Double-bounded curves cannot return results lesser than `lowerValue` or greater than `upperValue`. • C++

• C#

``auto doubleBounded = BoundedCurve<LinearFunction>{lowerValue, upperValue, gradient, intercept};``
``````Curve linearCurve = new LinearFunction(gradient, intercept);
BoundedCurve doubleBounded = new BoundedCurve(linearCurve, lowerValue, upperValue);``````