math behind scale?
May 17, 2010 at 7:30am
math behind scale?
Can someone give me some details about the math behind the scale object?
May 17, 2010 at 10:21am
I 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″
This still ignores the exponential part, but I don’t think this should be too hard to figure out as well.
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 at 11:26am
here’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”.
May 17, 2010 at 8:22pm
Woops, I didn’t now that the formula is inside the docs.
Thanks a lot guys!
Jun 28, 2010 at 10:39am
I 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
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 at 10:07pm
Please, 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 640×480 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.)
– Pasted Max Patch, click to expand. –
Copy all of the following text.Then, in Max, select New From Clipboard.
Jun 30, 2010 at 10:34pm
Could you just multiply by -1. after the scale?
[jit.op @op * @val -1.]
Jun 30, 2010 at 11:04pm
I guess it’s mid school mathematics! I’m loosing my mind!!
Thank you so much, Jesse!!
You must be logged in to reply to this topic.