Arbitrary function using piece-wise linear interpolaton
Here is a function for producing an output value that is an arbitrary function of the input value. I've written this function 3 or 4 times in my career now, so I hope I got it generic enough this time that I won't need to write it again! Only the first polymorphic form of the function has been implemented. Creating the other polymorphs is trivial and left as an "exercise for the reader".
About this Code Example
Further documentation is included in the header file.
This is a "pure" function which has no side effects nor specific requirements from the target platform. The tools and target listed above are merely what the code was developed and tested on. It ought to compile and run on any platform that supports C and floating point.
- Nov 26, 2011