# Constrain Within Circle?

TJ Frame tjframe at gmail.com
Sat Nov 5 03:17:17 EST 2005

```Here is a quick 1 minute hack - please no chastizing me on the "repeat while
the mouse is down" stuff. You can obviously turn this into a fancy self
contained function with params stuff..
-- button script
on mousedown
put the loc of grc "Circle" into circleLoc
put (the width of grc "Circle")/2 into tLength
repeat while the mouse is down
put the mouseloc into mLoc
put findLength(circleLoc, mLoc) into tDistance
if tDistance < tLength then
set the loc of me to mLoc
else
set the loc of me to findSegmentPoint (mLoc, circleLoc, tLength)
end if
end repeat
end mousedown

function findLength p1,p2
return round(sqrt((item 1 of p2 - item 1 of p1) ^ 2 + (item 2 of p2 - item 2
of p1) ^ 2))
end findLength

function findSegmentPoint pointA, pointB, tLength
put -tLength/findLength (pointA,pointB) into tRatio
return round(item 1 of pointB - tRatio * (item 1 of pointA - item 1 of
pointB)) & comma & round(item 2 of pointB - tRatio * (item 2 of pointA -
item 2 of pointB))
end findSegmentPoint

On 11/4/05, MisterX <b.xavier at internet.lu> wrote:
> I haven't worked all the geometry functions available yet ;)
> don't know the arcade engine
>
> but here's a good source:
>
> http://www.2dcurves.com/conicsection/conicsectionc.html
>
> that's the place for curves ;)
>
> other wise wolfram's reference is absolutely great.
>
> but coming to thing of it, my pie control must do something like
> that...
>
> http://www.monsieurx.com/modules.php?name=News&file=article&sid=162
>
> there's a setting button to offset the fields in and out of the
> center of the pie chart. That's the one you are looking for...
>
> the pseudo script would say
>
> r = radius of circle
> xy = center of circle or arc
> xyR[1..4] are the polygon's rects,
>
> for each item I in xyR
> if distance xy -> I > r
> you're out of the circle...
>
> cheers
> Xavier
>
>
> > -----Original Message-----
> > From: use-revolution-bounces at lists.runrev.com
> > [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of
> > Scott Rossi
> > Sent: Saturday, November 05, 2005 7:13 AM
> > To: How to use Revolution
> > Subject: Constrain Within Circle?
> >
> > Anyone have a formula to constrain object dragging within a
> > circular region?
> >
> > I'm guessing something like Arcade Engine has this in it, but
> > I really only need this one function.
> >
> > Thanks & Regards,
> >
> > Scott Rossi
> > Creative Director
> > Tactile Media, Multimedia & Design
> > -----
> > E: scott at tactilemedia.com
> > W: http://www.tactilemedia.com
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage
> > http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

```