Constrain Within Circle?

Jim Hurley jhurley at infostations.com
Sat Nov 5 19:08:30 EST 2005


>
>From: Roger Guay <irog at mac.com>
>
>Cool, Jim.  And, if you change just one line of your code in the 
>mouseMove handler to
>
>                                                                         
>                "if   rr is not r then"
>
>you get an object that is constrained to move on the circle of radius
>rr.  This is useful if you want to build a rotary knob for example.
>


Roger,

Scott and I were working on a problem like the one you describe some 
time ago. But  the question was: Could the rotary knob be used to 
*accumulate* multiple turns by  following the the polar angle. The 
difficulty here was that the angle as reported by RR using the atan2 
function is single valued, that is it returns to the same value after 
one complete revolution. How then do you record the angle *plus* the 
number of revolutions?

But as the knob crosses the branch cut where the angle changes from 
360 back to 0, one can detect this large discontinuity using 
something like: if abs(da) > some small number then add 1 to the 
counter and multiply this  counter by 360, where da is the 
continuously measure difference in polar angle in the mouseMove 
function.

This is hard to explain. Easier to see: In the message box:

go stack url "http://home.infostations.net/jhurley/Clock.rev"

Jim



More information about the use-livecode mailing list