## Create a curved line. I'm bad at math.

Dec 5, 2011 at 1:00pm

# 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)

###### Attachments:
#60473
Dec 5, 2011 at 2:41pm

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

s

#217654
Dec 5, 2011 at 3:09pm

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:

– Pasted Max Patch, click to expand. –

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

#217655
Dec 5, 2011 at 9:20pm

you can get that into one line of code like in my recent post here:

http://cycling74.com/forums/topic.php?id=36275

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

#217657

You must be logged in to reply to this topic.