(Basic?) math Issue

    Nov 15 2017 | 12:50 am
    I am very tired so forgive me if the answer is quite obvious ;)
    I want to use the output of a slider so that when the slider is at 0 it actually outputs a large value. And when the slider is at its highest point then it outputs something closer to 0. The slider is not important but just using it as a visual idea to get the scenario across.
    So basically, if the slider is dropping from e.g.. 4 to 0..... 4, 3, 2, 1, 0...... I actually want it to output 0, 1, 2, 3, 4.
    An issue is that I cannot predict the maximum value, as it is based on other changing data. All I know is that the values will never go below 0. So from 0 to "?".
    So far maths is failing me so perhaps there is a dead easy solution to this I'm not aware of?
    Any tips much appreciated :)

    • Nov 15 2017 | 1:35 am
      Does this do what you want?
    • Nov 15 2017 | 2:10 am
      Thanks, BKSHEPARD. That is exactly the outcome I want.... but the issue is that I cannot predict the maximum incoming value. I think in your example, you must manually set this max. Am I correct?
      Perhaps I can expand. My fundamental problem is that I am dealing with values that go positive and negative across a 0 axis. I wish to output higher values as the graph swings closer to the 0 axis (either side of it).
      Here is a screen shot of this scenario, graphed. Left is negative and right is positive.
    • Nov 15 2017 | 9:13 am
      1. it is impossible to map an unknown value to 0. you have to find it out or arbitrarily set the max number.
      2. you can split an incoming range with split (or better with clip when the input is coming from mouse or sensor input), then reverse the positive range with !- 100. and the negative range with * -1. , !- 100. , * -1. .
      3. as usual, it will also fit into one line: expr ($f1<0.) * (-1. * ($f2 - (abs($f1))) ) + ($f1>=0.) * ($f2 . - $f1) where the second input is the max number, i.e. expr ($f1<0.) * (-1. * (100. - (abs($f1))) ) + ($f1>=0.) * (100. - $f1)
    • Nov 15 2017 | 2:51 pm
      Thank you very very much, Roman :) I'll try this out asap and report back.
      The "arbitrary" max number... I figured that was the issue.
      Perhaps there is a way I can detect and store the last max (+) and min(-) as it sways back and forth and store that value temporarily to be input as "$f2"(the maximum) above.
    • Nov 15 2017 | 4:47 pm
      if the data is coming from a sensor or a gaussian noise, i would do exactly that, let it run for 1000 times or for 3 seconds and then use minimum and maximum to find a useful forced limit.
    • Nov 15 2017 | 5:13 pm
      Since I didn't know where your unknown value was coming from, I just represented it with an integer object. My thinking was that whatever was outputting the unknown value would replace the integer object.
    • Nov 16 2017 | 1:37 pm
      You can store the last x values in a list with zl.stream, then find the min and max values from that list and use the scale object to adjust the scale dynamically, including reversing the output.
    • Nov 17 2017 | 10:41 am
      Hi, BhShepard. I see your thinking now with the integer object. Thanks again :) Thank you once again also, Roman :)