Create a curved line. I'm bad at math.
Hi everyone,
I've got a question.
I'm receiving a range of numbers from a sensor via an arduino. The range is 0-1023.
512 will be the center point. When it moves from center to min or max, it has to do this exponentially.
My question: what line function do I need to use. My math ain't that great.
I hope some one will understand my question (don't really know how to explain better),
so I've added a picture to help you understand my question. (it's line1.jpg, ignore the other one)
I'm bad at math too and max think about us :) check the curve~ object...it outputs signal so not sure if it is what you want...
cheers
Hi
the most basic curve can be generated thus: input integer --> [pack i 100] --> [line] --> curve output; however, the fifth argument to [scale] provides for exponential mapping:
And Sergio is right to suggest [curve~], but it will only create nice curves if the input is linear.
Check out the helpfiles for [expr], [function], [itable] and [multislider], they are also often used to remap input values in this way.
Brendan
also take a look at the jit.path object, which will allow you to edit the curve using handles, as well as easily visualize the curve in opengl.
below is a patch and screenshot.
i scaled the range by 1000 for easier opengl visualization.
you can get that into one line of code like in my recent post here:
the abstarction is also somewhere here in the forums.
but i would suggest that you find your own was by breaking the
problem down into smaller tasks:
1. split the range into three ranges of 0-511, 512, and 513-1023
2. reverse the direction of the lower part
3. perform the desired distortion with log, exp or whatever you wish while keeping the input range.
4. reverse the 511-0 back to 0-511
5. mix the thre rages back to one ...
-110