keep thr absoulute value between two points

R_Gol's icon

I have input from sensor that sends data between -1 and 1. For the example here assuming using the mouse input of x axes.

I would like to mesure two points on screen: min and max.

When pressing 1 I get point 1(assume 100) and when pressing 2 I'm getting point 2( assume 300).

this distance can use now to control max 4 live api and move a knob full distance between 0 and 1.

(scaling 100 and 200 to 0 1)

after taking two points location(100,300) I move the mouse to a different place on screen and when pressing number 3 it will start to output the same difference number mesured between point 1 and 2 just in a different place on screen. ( so the dame distance will be also able to map a api know between 0 1 if the same distance is reached

so if I press 3 (number 500 on screen) it will output the same number as the difference bewtween point 1 and 2.

R_Gol's icon

Here is a trial that seems to work with positive numbers. I wonder how this could work if the inputs is also numbers below zero

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

I press 1 when on the left edge side of the blue square then press 2 when on the right edge of the blue square.

when press 3 on the left hand edge side of the green screen and move the mouse in its area I can see the output is between 0 and 1. same with the red square.

any thoughts?

Source Audio's icon

where is blue square ?

there could be no input below zero

if you use mousestate mode 0 - screen related.

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

here is a bit simplified patch,

both ranges can be anywhere, even overlap.

if you manage to get input below zero , please explain how.

to avoid banging 0. or 1. all the time when

mouse is out of control range change 0. is inserted

R_Gol's icon

Thanks! looks much clearer

I can guess that the same can be apply to y axis.

what if I would like to apply to both x and y - is it possible?

Source Audio's icon

why not ?

I mean you just duplicate all and feed y instead of x.

Would you use x and y totally independent,

or maybe as a square ?

R_Gol's icon

or maybe as a square ?

This

Source Audio's icon

This what ?

And how ?

Maybe capture 1 square using keys 1 & 2 .

it would need top left, bottom right corners of 1st square to

start with, then you place mouse somewhere and press 3

from that point square gets set to right and down ?

R_Gol's icon

like this?

seems not to work as it should

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

Source Audio's icon

Here is example to set 1 square pressing key 1 for up left, key 2 for down right corners.

Then press 3 to set square 2 left top corner.

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

P.S.

I prefer to have 0 ~1 down to up,

if you want it opposite, remove !- 1.

R_Gol's icon

Thanks although I have some issue with the above patch:

I start at point 1 by pressing 1 and move in straight line towards point 2 then pressing 2.

numbers at the black square will move between 0 and 1 while moving on that line.

I then go with the mouse to point 3 then press the number 3. When moving with the mouse towards "finish" point in straight line I'm expecting the numbers at the green box to move as well between 0 and 1. This is not happening. What am I missing?

Source Audio's icon

Here is example to set 1 square pressing key 1 for up left, key 2 for down right corners.

Then press 3 to set square 2 left top corner.

your screenhot shows opposite.

R_Gol's icon

may I ask what is the needs for all those boolean expressions?

Source Audio's icon

they turn on output only when mouse is within square.