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

Aug 23, 2010 at 2:01am

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

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.

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.

– Pasted Max Patch, click to expand. –
#51923
Aug 23, 2010 at 5:22am

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

– Pasted Max Patch, click to expand. –
#186330
Aug 23, 2010 at 11:34am

Hello maxers,

– Pasted Max Patch, click to expand. –

HTH

#186331
Aug 23, 2010 at 12:26pm

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

#186332
Aug 23, 2010 at 2:45pm

Hello Scott,

yep ; i tried first with cosinus and so and finally after few hours ;-) …

i think you can loose several degrees when you go across the 359/0 gap, but if you don’t care about, [accum] is a simple way ;

if anybody know how to do it with trigonometric equations, i would like to know the solution ; it may be easy, but …

#186333
Aug 23, 2010 at 7:31pm

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.

#186334
Aug 24, 2010 at 3:23am

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:

– Pasted Max Patch, click to expand. –
#186335
Aug 24, 2010 at 7:40am

Hello maxers,

@MIB : oops …

@Scott : finally … don’t know why i have not founded it before …

– Pasted Max Patch, click to expand. –

but loose degrees too ; maybe fix it increasing steps ; naive way best ?

#186336

You must be logged in to reply to this topic.