expr graph examples?

karl krach's icon

hi,
ok, this is embarassing but...: i regularly keep bumping into the problem that i need to scale one number to another using some function - of which i usually have some sort of visual idea but unfortunately no mathematical understanding whatsoever - eg. in the moment i would need to have something like [scale] but which works with a bell-shape sort of curve.
now, i know this can all be done with basic math knowledge and [expr] but since it takes me days to figure this out each time: is there some sort of visual cheat sheet for super-dummies somewhere? like some document showing (visually) a range of graphs with the according expressions (in the format [expr] understands) and maybe a simple explanation (like: "if you want this curve to be less steep, decrease this number")?
that would be sooooo helpful...
k

Roman Thilenius's icon

u could build the chart yourself using lcd.

u might want to start with my old style abstractions found at https://cycling74.com/forums/re-mapping-a-range-of-numbers-add-your-tricks-here/

there is a little helpfile coming with it where you see in the input and output just as simple slider objects. mabye even better than a 2d-graph for most situations?

Roman Thilenius's icon

oh btw, multislider belongs to thze objects whose default settings between v7 and earlier are not compatible. complints should go directly to support@ ... sorry guys ;)

Ploki's icon

`

Max Patch
Copy patch and select New From Clipboard in Max.

like this?

Also, go check in the help patcher of [scale], "advanced tab" offers a similar example with [itable]

What bugs me though, is why the multi slider "graph" changes if you change sample size, when using [scale]s exponent function. shouldn't it stay the same? Or am I not imaging things right?

edit: what you also want to check is "function graphs" (google it) and Max tutorial #22 "Designing equations"

edit: i keep editing stuff in my patcher. You can enable a "curve" in the function to get S curves or custom scaling

Roman Thilenius's icon

btw, the only way to find functions from given curves would be to test all known functions against it.

not even wolfram alpha can do that:

but it will help you find the function for a bell curve:

well, if you can read this stuff. i cant. :)

but luckily i know it by heart:

[exp(-(($f1-0.5)/0.125)*(($f1-0.5)/0.125))]

this works for a range of 0. 1.

you can adapt it to other ranges by multiplying the 4 constants.

or do it like i do it in my abstractions: first scale to 0.-1., then apply the curve, then scale again to whatever you wish.

-110

Ernest's icon

What I do is use a bezier function.For display, I build the curve with an uzi between start and end points,because I wanted a display in 30x50-pixel thumbnail which I couldn't create otherwise,. I have to say, it is not easy to program in Max. You will find my first implementation in Godel 2b on my website.

karl krach's icon

oh, wow!
thank you all so much for your help! combining all these tips and ressources i guess i do get quite close to my "graphs cheat-sheet for superdummies"... nice!

one last question (which is only vaguely related but as i seem to have gathered all the math pros already): how would i rearrange this function so it calculates α (α = ... ... ...) instead of G?
G = 2 × d × tan(α / 2)
(using: G=Field of view, d=Distance, α=Angle of view)
and how would i format this so [expr] would understand it?

Roman Thilenius's icon

wolfram alpha had replaced mathematica for me since it allows you to ask it things like this:

"G = 2 × d × tan(α / 2) α=?"

i am not sure how to write the "-1" (inverse tangent) in expr, and i know what the the "n" in "pi*n" means and where it comes from either.

-110

karl krach's icon

most interesting! i didn't know wolfram alpha could do this...
regarding the inverse tangent, this seems to be "atan", regarding the "n"... no idea.
apart from the "n" i think this should be something like [expr exp(2*(atan($f1/(2*$f2))+3.1416))]. am i correct?
but what is this mysterious "n"?

Jean-Francois Charles's icon

tan(-1) is atan
We know that tan(x) = tan(x + π) = tan(x + nπ), with n any integer.
So Wolfram gives you the complete set of possible values for α.
You will implement this with n=0, i.e. you will ignore the "+ n π".

karl krach's icon

perfect, works like a charm!
thanks again!!!
k