May 17 2010 | 7:30 am

Can someone give me some details about the math behind the scale object?
Thanks!

- May 17 2010 | 10:21 amI don't have access to the scale source code, but I can make a guess.The linear part is easy:- Subtract the low input value from the number, then divide the result by the difference between high input value and low input value. This gives you a number between 0 and 1.- Then multiply this again with the difference between low output and high output value, and finally add the low output value.As an expression, this would look like this:expr "(($f1-$f2)/($f3-$f2)) * ($f5-$f4) + $f4" $f1 being your number input, $f1 the low input value, $f2 the high input value, $f3 the low output value, $f4 the high output value.This still ignores the exponential part, but I don't think this should be too hard to figure out as well.EDIT:eh, I'm silly. Should have looked into the documentation of [scale] first where the formula is written down. So that's what you should do as well!
- May 17 2010 | 11:26 amhere's the formula from the docs:y = b*e^(-a*log(c)) * e^(x*log(c))it says "a,b and c are the three typed-in arguments". So c is the exponential factor and e is the base of the natural logarithm. But what's a and b ??
- May 17 2010 | 8:22 pmWoops, I didn't now that the formula is inside the docs.Thanks a lot guys!
- Jun 28 2010 | 10:39 amI think that what is written in the docs is for exponential mode calculations. I was interested as well to use a jit.expr expression that simulates the scale object.I managed to do something similar to [scale 0 255 -1. 1.] with the following expresion[expr (in[0]/255-0.5)*2]but I don't have a clue how to do [scale 0 255 1. -1.]Does anyone know? I'm not good at maths either
- Jun 30 2010 | 10:07 pmPlease, if anyone knows how to reverse a scale in jit.expr. I am trying to reverse a short matrix with 2d xy coordinates for a 640x480 pixels to have 3d xy coordinates which are -1. 1. for both x and y (with the center as 0.).I did the first part for the x coordinate where 0 becomes -1. and 640 becomes 1. But for the y value, 0 is 1. and 480 is -1.So I would need an expresion for jit.expr to turn a (-1. 1) matrix the other way around (1. -1.)
- Jun 30 2010 | 10:34 pmCould you just multiply by -1. after the scale?[jit.op @op * @val -1.]
- Jun 30 2010 | 11:04 pmI guess it's mid school mathematics! I'm loosing my mind!!Thank you so much, Jesse!!