Quote:
Originally Posted by Bpk9p4
sorry no both ways work just as well. Just was putting out another option. We have just had good luck with this method. here is an example of how we use it http://i.imgur.com/Bq7QMuE.png
|
You mentioned you were using a Lookup Table for that.
Just for fun, when you have a symmetric piecewise linear curve like that with so few pieces, you can create a very simple tunable piecewise linear function.
I labeled the points (a,0), (a,b), and (c,d) on your diagram (attached).
C code for the piecewise linear code for that is quite simple:
Code:
// do the following once at initialization,
// or any time you change a ,b, c, or d on-the-fly:
m1=(d-b)/(c-a); m2=(1-d)/(1-c);
Code:
// Let J be the abscissa and K be the ordinate on your graph.
// Here's the piecewise linear code to convert J to K:
x=fabs(J);
if (x<a) K=0;
else if (x<c) K=b+m1*(x-a);
else K=d+m2*(x-c);
if (J<0) K=-K;