detecting left or right rotation from an arbitrary point on a circle

Scott Fitzgerald's icon

Hey forum.

I'm building out a TUIO interface in which a fiducial is going to act like a binary knob. If you turn it to the right more than 30 degrees, an action happens. If you turn it to the left more than 30 degrees, a different action happens.

There is nothing on the physical object to indicate which end is "up", the zero point. he TUIO software give me the fiducial's rotation in values from 1-360. By taking the initial angle and subtracting/adding 30, I can easily find if it has passed the threshold for the action, unless the area of change happens in the crossover between 1 and 360.

How can my mathematically challenged self get around this? All I have so far is a simple utility that will record every 30 degrees and set a new reference point. I'd like a way to wrap the values so i can tell direction.

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

Attached is a patch that replicates 1) what I have so far, and 2) the setup with a dial and randomly generated value. Thanks for your help.

Scott Fitzgerald's icon
Max Patch
Copy patch and select New From Clipboard in Max.

While I was looking for a mathematical solution, I settled for a simple (and messy) conditional system.

Scott Fitzgerald's icon

Thanks, an excelent solution (accum! I always forget about him)

Scott Fitzgerald's icon

Yeah, my intent was to figure out a way with trig as well. Your accum patch works well enough for this particular system.

maybe later in the week I can revisit the issue.

MIB's icon
Max Patch
Copy patch and select New From Clipboard in Max.

don't have anything to add per se. just wanted to make a comment on pizza olives' "delta" patch. there is an easier way of getting delta values, with less objects. Probably doesn't make much of a difference in terms of performance. just thought I would share: