Core 1.0
Static Public Member Functions | Static Public Attributes | List of all members
Math Class Reference

Core class implementing some useful functions and constants. More...

#include <mathematics.h>

Static Public Member Functions

static double Clamp (const double &, const double &=0.0, const double &=1.0)
 Clamp a double value between two bounds. More...
 
static int Clamp (int, int=0, int=255)
 Clamp an integer value between two bounds. More...
 
static double Sqr (const double &)
 Squares a double value. More...
 
static constexpr double Cube (const double &)
 Cubes a double value. More...
 
static double Sqr4 (const double &)
 Fourth power of a double value. More...
 
static double SymmetricSqr (const double &)
 Symmetric of square function over unit interval. More...
 
static double Pow (const double &, const double &)
 Power. More...
 
static double Abs (const double &)
 Absolute value. More...
 
static double Sqrt32 (const double &)
 Compute x3/2 as the square root of x3. More...
 
static double Sqrt4 (const double &)
 Compute the fourth root of x3. More...
 
static void Powers (const double &, int, double *)
 Compute the powers series of a real value 1, x, ... , xn-1. More...
 
static constexpr double Mod (const double &, const double &)
 Modulus for reals with negative values handled properly. More...
 
static double Floor (const double &)
 Floor function. More...
 
static double Fract (const double &)
 Fractional part of a real. More...
 
static double FractFloor (const double &, double &)
 Fractional part of a real. More...
 
static double Ceil (const double &)
 Ceil function. More...
 
static double Min (const double &, const double &)
 Minimum of two reals. More...
 
static double Max (const double &, const double &)
 Maximum of two reals. More...
 
static double Min (const double &, const double &, const double &)
 Minimum of three reals. More...
 
static double Max (const double &, const double &, const double &)
 Maximum of three reals. More...
 
static double Min (const double &, const double &, const double &, const double &)
 Minimum of four reals. More...
 
static double Max (const double &, const double &, const double &, const double &)
 Maximum of four reals. More...
 
static constexpr double DegreeToRadian (const double &)
 Convert degrees to randians. More...
 
static constexpr double RadianToDegree (const double &)
 Convert radian to degrees. More...
 
static constexpr double Angle (int, int)
 Compute 2 k π / n. More...
 
static constexpr double Angle (const double &)
 Angle strictly in [0,2 π[. More...
 
static double ArcTan (const double &, const double &)
 Inline version of the atan2() function.
 
static double Step (double, double)
 Step function. More...
 
static double Cycloidal (const double &)
 Sine wave over unit interval. More...
 
static double Triangle (const double &)
 Triangle wave over unit interval. More...
 
static double Lerp (const double &, const double &, const double &)
 Linear interpolation. More...
 
static double Bilinear (const double &, const double &, const double &, const double &, const double &, const double &)
 Bi-linear interpolation between four values. More...
 
static double Trilinear (const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &)
 Trilinear interpolation between eight values. More...
 
static double Cubic (const double &, const double &, const double &, const double &, const double &)
 Cubic Hermite interpolation. More...
 
static double CubicPoints (const double &, const double &, const double &, const double &, const double &)
 Cubic point interpolation. More...
 
static double BiCubic (const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &=0.0, const double &=0.0, const double &=0.0, const double &=0.0)
 Bi-cubic interpolation between four values, given partial derivatives. More...
 
static double BiCubic (const double &, const double &, const double &, const double &, const double &, const double &)
 Bi-cubic interpolation between four values, partial derivatives are implicitly defined as null. More...
 
static double Sigmoid (const double &, const double &=1.0)
 Sigmoid-like function. More...
 
static double SigmoidQuadric (const double &)
 Compactly supported sigmoid-like function implemented using a C1 piecewise symmetric quadric. More...
 
static double Impulse (const double &, const double &=1.0)
 Impulse function. More...
 
static double Warp (const double &)
 Unit interval warping function. More...
 
static double Warp (const double &, const double &)
 Unit interval gain function. More...
 
static bool InRange (const double &, const double &, const double &, const double &)
 Check if a values lies within a prescribed range. More...
 
static void SetMinMax (const double &, double &, double &)
 Update the minimum and maximum values given a double value. More...
 
static int Integer (const double &)
 Compute the integer part of a real. More...
 
static void Sort (double &, double &)
 Sort two reals. More...
 
static void Sort (int &, int &)
 Sort two integers. More...
 
static void Sort (double &, double &, double &)
 Sort three reals. More...
 
static void Swap (double &, double &)
 Swap two reals. More...
 
static void Swap (int &, int &)
 Swap two integers. More...
 
static bool IsNumber (double)
 Check if a real number is not NaN. More...
 
static bool IsFinite (double)
 Check if a real is not infinite. More...
 
static int IntegerSign (const double &, const double &=0.0)
 Compute the integer sign of a real. More...
 
static bool SameSign (const double &, const double &)
 Check if two reals have the same signs. More...
 
static bool SameSign (const double &, const double &, const double &)
 Check if three reals have the same signs. More...
 
static double CopySign (const double &, const double &)
 Composes a real with the magnitude of x and the sign of y. More...
 
static long Binomial (int, int)
 Calculate the Binomial coefficent. More...
 
static constexpr double Unit (int, int)
 Unit real value in [0,1] from two integers. More...
 
static double Gaussian (const double &, const double &)
 Gaussian. More...
 
static double CompactGaussian (const double &, const double &)
 Compact support Gaussian approximation. More...
 
static double Fract (const double &, double &)
 Compute integer and fractionnal parts. More...
 
static double Fract (const double &, const double &, double &)
 Compute integer and fractionnal parts. More...
 
static double Fract (const double &, const double &, const double &, double &)
 Compute integer and fractionnal parts given an interval. More...
 
static double Geometric (double, int)
 Compute the sum of the terms of a geometric series. More...
 
static void Swap (double *&, double *&)
 Swap two reals. More...
 
static void Swap (int *&, int *&)
 Swap two integers. More...
 
static void BernsteinSeries (const double &, int, double *)
 Compute the Bernstein terms.
 
static double Bernstein (const double &, int, int)
 Compute the i-th Bernstein term.
 

Static Public Attributes

static const double Pi = 3.14159265358979323846
 π.
 
static const double TwoPi = 6.28318530717958647693
 2π.
 
static const double HalfPi = Math::Pi / 2.0
 Half of π.
 
static const double e = 2.7182818284590452354
 Exponential.
 
static const double TwoPiOverThree = 2.0943951023931954923084
 2/3 π.
 
static const double FourPiOverThree = 4.1887902047863909846168
 4/3 π.
 
static const double Sqrt5 = sqrt(5.0)
 Constant √5.
 
static const double Sqrt3 = sqrt(3.0)
 Constant √3.
 
static const double Sqrt2 = sqrt(2.0)
 Constant √2.
 
static const double Golden = (sqrt(5.0) + 1.0) / 2.0
 Constant (√5+1)/2.
 
static const double Large = 1.0e20
 Large constant 1020.
 
static const double Infinity = DBL_MAX
 Infinity.
 
static int binomials [16][16]
 Array of binomial coefficients.
 

Detailed Description

Core class implementing some useful functions and constants.

How can I use the constant Pi?
Simply use the static constant Math::Pi as follows:

double v = 4.0*Math::Pi*r*r*r/3.0; // Volume of a sphere.
static const double Pi
π.
Definition: mathematics.h:174

Note that in this case, you could also have used:

double v = Sphere::Volume(r);
double Volume() const
Compute the volume of the sphere.
Definition: sphere.h:146

How many min/max functions have been implemented?
Up to four arguments are supported; for a larger number of arguments, a specific routine operating on an array should be written.

Is there a function to compute the square of a real sumber?
Use the following:

double s = Math::Sqr((1.0-sqrt(5.0))/2.0); // Square of golden ratio
static double Sqr(const double &)
Squares a double value.
Definition: mathematics.h:335

For a Vector, use SquaredNorm(const Vector&);

Are there predefined square roots constants?
The sqrt function used not te be constexpr, so square roots of reals are not computed at compilation time. Some constants are provided, such as the following one:

double s = Math::Sqrt3; // Square root of 3
static const double Sqrt3
Constant √3.
Definition: mathematics.h:181

What is the relative performance of mathematical functions such as square root or cosine?
The relative cost of commonly used mathematical functions is summarized in the following table.

Cost
FunctionCost
+ - * fabs1
/ sqrt modf ~4.8
/ sin cos ~8.9
/ exp log ~10.5

Math provides some functions such as Math::Sqrt32 or Math::Sqrt4 to avoid computationally intensive standard functions like pow:

double y = Math::Sqrt32(x); // Faster than double y = pow(x,1.5);
static double Sqrt32(const double &)
Compute x3/2 as the square root of x3.
Definition: mathematics.h:349

How are implemented the step and smooth-step functions that are often used in procedural modeling? Different smoothing kernels, such as Cubic::Smooth(), are implented in odd-degree polynomials Cubic, Quintic and Septic. The corresponding step functions, such as Cubic::SmoothStep(), are also implemented.

See also
Linear::Step, Cubic::Smooth, Quintic::Smooth, Cubic::SmoothStep, Quintic::SmoothStep, Septic::SmoothStep.

Member Function Documentation

◆ Abs()

double Math::Abs ( const double &  x)
inlinestatic

Absolute value.

Parameters
xReal.

◆ Angle() [1/2]

constexpr double Math::Angle ( const double &  a)
inlinestaticconstexpr

Angle strictly in [0,2 π[.

Parameters
aAngle.

◆ Angle() [2/2]

constexpr double Math::Angle ( int  k,
int  n 
)
inlinestaticconstexpr

Compute 2 k π / n.

Parameters
k,nIntegers.

◆ BiCubic() [1/2]

double Math::BiCubic ( const double &  u,
const double &  v,
const double &  a00,
const double &  a10,
const double &  a11,
const double &  a01 
)
static

Bi-cubic interpolation between four values, partial derivatives are implicitly defined as null.

This is an optimized implementation.

Parameters
u,vInterpolation coefficients.
a00,a10,a11,a01Interpolated values.

◆ BiCubic() [2/2]

double Math::BiCubic ( const double &  u,
const double &  v,
const double &  a00,
const double &  a10,
const double &  a11,
const double &  a01,
const double &  u00,
const double &  u10,
const double &  u11,
const double &  u01,
const double &  v00,
const double &  v10,
const double &  v11,
const double &  v01,
const double &  x00 = 0.0,
const double &  x10 = 0.0,
const double &  x11 = 0.0,
const double &  x01 = 0.0 
)
static

Bi-cubic interpolation between four values, given partial derivatives.

The values are given in trigonometric order.

Parameters
u,vInterpolation coefficients.
a00,a10,a11,a01Interpolated values.
u00,u10,u11,u01,v00,v10,v11,v01Partial derivatives with respect to u and v.
x00,x10,x11,x01Cross derivatives.

◆ Bilinear()

double Math::Bilinear ( const double &  a00,
const double &  a10,
const double &  a11,
const double &  a01,
const double &  u,
const double &  v 
)
inlinestatic

Bi-linear interpolation between four values.

The values are given in trigonometric order.

Parameters
a00,a10,a11,a01Interpolated values.
u,vInterpolation coefficients.

◆ Binomial()

long Math::Binomial ( int  n,
int  r 
)
static

Calculate the Binomial coefficent.

Parameters
n,rBinomial coefficient parameters.

◆ Ceil()

double Math::Ceil ( const double &  x)
inlinestatic

Ceil function.

See also
Floor
Parameters
xReal.

◆ Clamp() [1/2]

double Math::Clamp ( const double &  x,
const double &  a = 0.0,
const double &  b = 1.0 
)
inlinestatic

Clamp a double value between two bounds.

Parameters
xInput value.
a,bLower and upper bounds.

◆ Clamp() [2/2]

int Math::Clamp ( int  x,
int  a = 0,
int  b = 255 
)
inlinestatic

Clamp an integer value between two bounds.

Parameters
xInput value.
a,bLower and upper bounds.

◆ CompactGaussian()

double Math::CompactGaussian ( const double &  x,
const double &  s 
)
inlinestatic

Compact support Gaussian approximation.

The compact support has a radius r = 3 sigma.

Parameters
xReal.
sSigma.

◆ CopySign()

double Math::CopySign ( const double &  x,
const double &  y 
)
inlinestatic

Composes a real with the magnitude of x and the sign of y.

Parameters
xReal.
yReal whose sign will be copied.

◆ Cube()

constexpr double Math::Cube ( const double &  x)
inlinestaticconstexpr

Cubes a double value.

Parameters
xReal value.

◆ Cubic()

double Math::Cubic ( const double &  u,
const double &  a,
const double &  b,
const double &  ta,
const double &  tb 
)
static

Cubic Hermite interpolation.

Parameters
uInterpolation coefficient.
a,bValues for t=0 and t=1.
ta,tbDerivatives for t=0 and t=1.
See also
Cubic::Hermite()

◆ CubicPoints()

double Math::CubicPoints ( const double &  u,
const double &  a,
const double &  b,
const double &  c,
const double &  d 
)
static

Cubic point interpolation.

Parameters
uInterpolation coefficient.
a,b,c,dValues for t=-1, t=0, t=1 and t=2. The derivatives at t=0 and t=1 will be derived from those
See also
Math::Cubic()

◆ Cycloidal()

double Math::Cycloidal ( const double &  x)
static

Sine wave over unit interval.

Parameters
xReal value.

◆ DegreeToRadian()

constexpr double Math::DegreeToRadian ( const double &  a)
inlinestaticconstexpr

Convert degrees to randians.

Parameters
aAngle in degrees.

◆ Floor()

double Math::Floor ( const double &  x)
inlinestatic

Floor function.

While it is easier to use the C++ function, this has been implemented to be consistent with Fract().

Parameters
xReal.

◆ Fract() [1/4]

double Math::Fract ( const double &  x)
inlinestatic

Fractional part of a real.

Implemented as:

double y=x-Math::Floor(x);
static double Floor(const double &)
Floor function.
Definition: mathematics.h:707
Parameters
xReal.

◆ Fract() [2/4]

double Math::Fract ( const double &  x,
const double &  a,
const double &  b,
double &  i 
)
inlinestatic

Compute integer and fractionnal parts given an interval.

Parameters
xReal.
a,bInterval.
iReturned integer part.
Returns
Fractional part.

◆ Fract() [3/4]

double Math::Fract ( const double &  x,
const double &  a,
double &  i 
)
inlinestatic

Compute integer and fractionnal parts.

Parameters
xReal.
aModulus.
iReturned integer part.
Returns
Fractional part.

◆ Fract() [4/4]

double Math::Fract ( const double &  x,
double &  i 
)
inlinestatic

Compute integer and fractionnal parts.

Parameters
xReal.
iReturned integer part.
Returns
Fractional part.

◆ FractFloor()

double Math::FractFloor ( const double &  x,
double &  y 
)
inlinestatic

Fractional part of a real.

Implemented as:

double y = x - Math::Floor(x);
Parameters
xReal.
yReturn floor.

◆ Gaussian()

double Math::Gaussian ( const double &  x,
const double &  s 
)
inlinestatic

Gaussian.

Parameters
xReal.
sSigma.

◆ Geometric()

double Math::Geometric ( double  x,
int  n 
)
static

Compute the sum of the terms of a geometric series.

Compute 1+x+x2+...+xn-1=(1-xn)/(1-x). If x=1.0, return n.

◆ Impulse()

double Math::Impulse ( const double &  x,
const double &  k = 1.0 
)
inlinestatic

Impulse function.

An impulse function that doesn't use exponentials, k controls the falloff of the function.

Derivative is 2*sqrt(k)*(1-k*x*x)/(k*x*x+1), maximum is reached x = sqrt(1/k), value at maximum is 1.

Parameters
kControl parameter.
xReal.

◆ InRange()

bool Math::InRange ( const double &  x,
const double &  a,
const double &  b,
const double &  epsilon 
)
inlinestatic

Check if a values lies within a prescribed range.

Parameters
xValue.
a,bInterval.
epsilonEpsilon tolerance.

◆ Integer()

int Math::Integer ( const double &  x)
inlinestatic

Compute the integer part of a real.

This function handles negative values differently by subtracting 1 from the result.

Parameters
xReal.

◆ IntegerSign()

int Math::IntegerSign ( const double &  x,
const double &  t = 0.0 
)
inlinestatic

Compute the integer sign of a real.

Parameters
xReal.
tThreshold.

◆ IsFinite()

bool Math::IsFinite ( double  x)
static

Check if a real is not infinite.

Parameters
xReal value.

◆ IsNumber()

bool Math::IsNumber ( double  x)
static

Check if a real number is not NaN.

The code is simply:

return (x == x);

This looks like it should always be true, but it's false if x is a NaN.

Parameters
xReal value.

◆ Lerp()

double Math::Lerp ( const double &  a,
const double &  b,
const double &  t 
)
inlinestatic

Linear interpolation.

Returns (1-t)a+tb.

Parameters
a,bInterpolated values.
tInterpolant.

◆ Max() [1/3]

double Math::Max ( const double &  a,
const double &  b 
)
inlinestatic

Maximum of two reals.

Parameters
a,bReal values.

◆ Max() [2/3]

double Math::Max ( const double &  a,
const double &  b,
const double &  c 
)
inlinestatic

Maximum of three reals.

Parameters
a,b,cReal values.

◆ Max() [3/3]

double Math::Max ( const double &  a,
const double &  b,
const double &  c,
const double &  d 
)
inlinestatic

Maximum of four reals.

Parameters
a,b,c,dReal values.

◆ Min() [1/3]

double Math::Min ( const double &  a,
const double &  b 
)
inlinestatic

Minimum of two reals.

Parameters
a,bReal values.

◆ Min() [2/3]

double Math::Min ( const double &  a,
const double &  b,
const double &  c 
)
inlinestatic

Minimum of three reals.

Parameters
a,b,cReal values.

◆ Min() [3/3]

double Math::Min ( const double &  a,
const double &  b,
const double &  c,
const double &  d 
)
inlinestatic

Minimum of four reals.

Parameters
a,b,c,dReal values.

◆ Mod()

constexpr double Math::Mod ( const double &  x,
const double &  a 
)
inlinestaticconstexpr

Modulus for reals with negative values handled properly.

Parameters
xReal.
aModulo.

◆ Pow()

double Math::Pow ( const double &  x,
const double &  e 
)
inlinestatic

Power.

Returns base x raised to the power exponent e if x>0, and -x raised to the power exponent e otherwise.

Parameters
xBase.
eExponent.

◆ Powers()

void Math::Powers ( const double &  x,
int  n,
double *  a 
)
inlinestatic

Compute the powers series of a real value 1, x, ... , xn-1.

Parameters
xReal.
nMaximum power.
aArray of real, should be at least of size n.

◆ RadianToDegree()

constexpr double Math::RadianToDegree ( const double &  a)
inlinestaticconstexpr

Convert radian to degrees.

Parameters
aAngle in radian.

◆ SameSign() [1/2]

bool Math::SameSign ( const double &  a,
const double &  b 
)
inlinestatic

Check if two reals have the same signs.

Parameters
a,bReals.

◆ SameSign() [2/2]

bool Math::SameSign ( const double &  a,
const double &  b,
const double &  c 
)
inlinestatic

Check if three reals have the same signs.

Parameters
a,b,cReals.

◆ SetMinMax()

void Math::SetMinMax ( const double &  x,
double &  a,
double &  b 
)
inlinestatic

Update the minimum and maximum values given a double value.

Parameters
xInput value.
a,bLower and upper bounds that will be updated according to x.

◆ Sigmoid()

double Math::Sigmoid ( const double &  x,
const double &  s = 1.0 
)
inlinestatic

Sigmoid-like function.

This function is more efficient than the real sigmoid function which requires the computation of the exponential.

Parameters
sSigma.
xReal.

◆ SigmoidQuadric()

double Math::SigmoidQuadric ( const double &  x)
inlinestatic

Compactly supported sigmoid-like function implemented using a C1 piecewise symmetric quadric.

The compact support is [-2,2] and the range [-1,1].

The quadric was obtaied by solving the Hermite Cubic contraints:

Cubic c=2.0*Cubic::Compose(Cubic::Hermite(0, 0.5, 1.0, 0.0), Linear(0.5, 0.0)) <<std::endl;
Cubic polynomials.
Definition: cubic.h:8
static Cubic Hermite(const double &, const double &, const double &, const double &)
Creates an Hermite cubic polynomial.
Definition: cubic.cpp:177
static Cubic Compose(const Cubic &, const Linear &)
Compose the cubic by a linear.
Definition: cubic.cpp:378
Linear polynomials.
Definition: linear.h:8
See also
Math::Sigmoid
Parameters
xReal.

◆ Sort() [1/3]

void Math::Sort ( double &  a,
double &  b 
)
inlinestatic

Sort two reals.

See also
Math::Swap(double&,double&)
Parameters
a,bReal arguments, which will be swapped so that a<=b.

◆ Sort() [2/3]

void Math::Sort ( double &  a,
double &  b,
double &  c 
)
inlinestatic

Sort three reals.

See also
Math::Sort(double&,double&)
Parameters
a,b,cReal arguments, which will be swapped so that a<=b<=c.

◆ Sort() [3/3]

void Math::Sort ( int &  a,
int &  b 
)
inlinestatic

Sort two integers.

See also
Math::Swap(int&,int&)
Parameters
a,bReal arguments, which will be swapped so that a<=b.

◆ Sqr()

double Math::Sqr ( const double &  x)
inlinestatic

Squares a double value.

See also
Math::SymmetricSqr
Parameters
xReal value.

◆ Sqr4()

double Math::Sqr4 ( const double &  x)
inlinestatic

Fourth power of a double value.

Parameters
xReal value.

◆ Sqrt32()

double Math::Sqrt32 ( const double &  x)
inlinestatic

Compute x3/2 as the square root of x3.

This function is more efficient than pow() which is extremely slow.

double y=Math::Sqrt32(7.0); // Equivalent but faster than y=pow(7.0,1.5);
Parameters
xReal value.

◆ Sqrt4()

double Math::Sqrt4 ( const double &  x)
inlinestatic

Compute the fourth root of x3.

This function is more efficient than pow() which is extremely slow.

double y=Math::Sqrt4(7.0); // Equivalent to y=sqrt(sqrt(7.0));
static double Sqrt4(const double &)
Compute the fourth root of x3.
Definition: mathematics.h:363
Parameters
xReal value.

◆ Step()

double Math::Step ( double  e,
double  x 
)
inlinestatic

Step function.

Parameters
eStep position.
xVariable.

◆ Swap() [1/4]

void Math::Swap ( double &  a,
double &  b 
)
inlinestatic

Swap two reals.

See also
Sort(double&,double&)
Parameters
a,bArguments.

◆ Swap() [2/4]

void Math::Swap ( double *&  a,
double *&  b 
)
inlinestatic

Swap two reals.

Parameters
a,bArguments.

◆ Swap() [3/4]

void Math::Swap ( int &  a,
int &  b 
)
inlinestatic

Swap two integers.

See also
Sort(int&,int&)
Parameters
a,bArguments.

◆ Swap() [4/4]

void Math::Swap ( int *&  a,
int *&  b 
)
inlinestatic

Swap two integers.

Parameters
a,bArguments.

◆ SymmetricSqr()

double Math::SymmetricSqr ( const double &  x)
inlinestatic

Symmetric of square function over unit interval.

Simply compute 1-(1-x)2.

See also
Math::Sqr
Parameters
xReal value.

◆ Triangle()

double Math::Triangle ( const double &  x)
static

Triangle wave over unit interval.

Parameters
xReal value.

◆ Trilinear()

double Math::Trilinear ( const double &  a,
const double &  b,
const double &  c,
const double &  d,
const double &  e,
const double &  f,
const double &  g,
const double &  h,
const double &  u,
const double &  v,
const double &  w 
)
inlinestatic

Trilinear interpolation between eight values.

See also
Math::Bilinear()
Parameters
a,b,c,d,e,f,g,hInterpolated values.
u,v,wInterpolation coefficients.

◆ Unit()

constexpr double Math::Unit ( int  i,
int  n 
)
inlinestaticconstexpr

Unit real value in [0,1] from two integers.

Usefull for loops, same as:

for (int i=0;i<n;i++)
{
double t=double(i)/double(n-1); // t=Math::Unit(i,n);
}
Parameters
i,nIntegers.

◆ Warp() [1/2]

double Math::Warp ( const double &  x)
inlinestatic

Unit interval warping function.

Remaps the unit interval into the unit interval by expanding the sides and compressing the center, keeping 1/2 mapped to 1/2.

Parameters
xReal in [0,1].

◆ Warp() [2/2]

double Math::Warp ( const double &  x,
const double &  k 
)
inlinestatic

Unit interval gain function.

Remaps the unit interval into the unit interval by expanding the sides and compressing the center, keeping 1/2 mapped to 1/2.

This function uses calls to pow and is computationally intensive.

See also
Quadric::Warp(const double&)
Parameters
xReal in [0,1].
kExponent.