On 16 December 2012 22:46, andy pugh <bodge...@gmail.com> wrote:

> It wouldn't be all that hard to make a linearisation curve component.

And it wasn't. Put the following in  a text file called
"lincurve.comp" then sudo comp --install lincurve.comp.

component lincurve "one-dimensional lookup table";
description """Performs a 1-dimensional lookup and interpolation. The x-val
parameters must be monotonic, though identical adjacent values are allowed.
(for example 0,0,0,10) for a 4-element curve. For input x less than the lowest
xval the y-val of the lowest is returned. For x greater than the largest x-val
the yval corresponding to x-max is returned (ie, no extrapolation is performed.
""";

param rw float y-val##[16:personality] "output values";
param rw float x-val##[16:personality] "input values";

pin in float x "The input value";
pin out float y "The output value";

variable unsigned i = 0;

option extra_setup yes;

author "andy pugh";
license "GPL";

function _;

;;

FUNCTION(_){
    double f;
    if (x >= x_val(personality-1)) {
        y = y_val(personality-1);
        return;
    }
    if (x <= x_val(0)) {
        y = y_val(0);
        return;
    }
    while (x > x_val(i+1)) { i++;}
    while (x < (x_val(i))) { i--;}

    f = (x - x_val(i))/(x_val(i+1)-x_val(i));
    y = y_val(i) + f * (y_val(i+1) - y_val(i));

}


EXTRA_SETUP(){
    if (personality > 16) personality=16;
    return 0;
}


-- 
atp
If you can't fix it, you don't own it.
http://www.ifixit.com/Manifesto

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to