ResponseCurve Class Template Reference

#include <C:/Work/specialnumbers_svn/NumberLib/NumbersLib/ResponseCurve.h>

Inheritance diagram for ResponseCurve:

AbstractFunction

List of all members.


Detailed Description

template<class T, unsigned int n>
class luma::numbers::ResponseCurve< T, n >

This class is described in AI Programming Wisdom 1, "The Beauty of Response Curves", by Bob Alexander.

Essentailly, this class provides a look-up table with linear interpolation for arbitrary functions.

Parameters:
n Number of output samples.
T The number type of the input and output, usually float or double.

Definition at line 24 of file ResponseCurve.h.


Public Member Functions

public T getInputMax () const
public T getInputMin () const
operator() (const T input) const
 If the input is below the inputMin given in the constructor, the output is clamped to the first output sample.
 ResponseCurve (T inputMin, T inputMax, T outputSamples[n])
 Constructs a new TransferFunction.

Private Attributes

mInputMax
mInputMin
mOutputSamples [n]
mPeriod
 The difference between two adjacent input values at sample points.

Constructor & Destructor Documentation

ResponseCurve ( inputMin,
inputMax,
outputSamples[n] 
) [inline]

Constructs a new TransferFunction.

Parameters:
inputMin The minimum value an input can be.
inputMax The maximum value an input can be.
outputSamples Samples of outputs.

Definition at line 70 of file ResponseCurve.h.

References ResponseCurve::mOutputSamples.


Member Function Documentation

T getInputMax (  )  const [inline]

Definition at line 107 of file ResponseCurve.h.

References ResponseCurve::mInputMax.

T getInputMin (  )  const [inline]

Definition at line 101 of file ResponseCurve.h.

References ResponseCurve::mInputMin.

T operator() ( const T  input  )  const [inline, virtual]

If the input is below the inputMin given in the constructor, the output is clamped to the first output sample.

If the input is above the inputMax given in the constructor, the output is clamped to the last output sample.

Otherwise an index is calculated, and the output is interpolated between outputSample[index] and outputSample[index + 1].

Parameters:
input The input for which output is sought.

Implements AbstractFunction.

Definition at line 82 of file ResponseCurve.h.

References luma::numbers::lerp(), ResponseCurve::mInputMax, ResponseCurve::mInputMin, ResponseCurve::mOutputSamples, and ResponseCurve::mPeriod.


Member Data Documentation

T mInputMax [private]

Definition at line 59 of file ResponseCurve.h.

Referenced by ResponseCurve::getInputMax(), and ResponseCurve::operator()().

T mInputMin [private]

Definition at line 58 of file ResponseCurve.h.

Referenced by ResponseCurve::getInputMin(), and ResponseCurve::operator()().

T mOutputSamples[n] [private]

Definition at line 60 of file ResponseCurve.h.

Referenced by ResponseCurve::operator()(), and ResponseCurve::ResponseCurve().

T mPeriod [private]

The difference between two adjacent input values at sample points.

Definition at line 66 of file ResponseCurve.h.

Referenced by ResponseCurve::operator()().


The documentation for this class was generated from the following file:

Generated on Sun Sep 21 20:49:08 2008 for Numbers by  doxygen 1.5.6