ANN: Dragging along a fixed path

Jim Hurley jhurley at infostations.com
Sun Aug 14 14:03:33 EDT 2005


>
>Message: 17
>Date: Sat, 13 Aug 2005 23:47:56 -0700
>From: John <jburtt at earthlink.net>
>Subject: Re: use-revolution Digest, Vol 23, Issue 31
>To: use-revolution at lists.runrev.com
>Message-ID: <p06210200bf24974e31f2@[172.16.1.11]>
>Content-Type: text/plain; charset="us-ascii" ; format="flowed"
>
>I've been working on much the same thing. My problem is that I have
>crossing lines
>and need to be able to drag either right, left, or straight. Any suggestions?
>
>John
>


John,

I have added a fourth card to the earlier stack that allows for crossing lines.

It is no longer possible to use the intersection function when moving 
along the lines of a closed polygon.

The best I could think of was dropping a perpendicular projection 
from the mouse loc to the crossing lines. (See function below.) The 
script sets the control to the closest of these projection points.

This can create some peculiar results after the mouse passes beyond 
the end points of a given line. So I require a certain minimum 
distance between the mouse loc and the projection point. If the mouse 
is moved too fast, the mouse will sometimes pass beyond this minimum 
and it  looses track of the control; you will have to move the mouse 
back until it is within this minimum. (I think I set it to 20 pixels. 
You can change this.)

In the message box:

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

and go to the last card.

Hope this works for you.

Jim


function thePerpProjPt2 p0, tLine
   put line 1 of tLine into p1
   put line 2 of tLine into p2
   put item 1 of p1 into x1
   put item 2 of p1 into y1
   put item 1 of p2 into x2
   put item 2 of p2 into y2
   put item 1 of p0 into x0
   put item 2 of p0 into y0
   if x2 = x1 then --Vertical line
     put 1 into s
     put 0 into c
   else
     put (y2-y1)/(x2-x1) into m
     put m/sqrt(1+m*m) into s --sine
     put 1/sqrt(1+m*m) into c -- cosine
   end if
   put x1+(y0-y1)*s*c+(x0-x1)*c*c  into x
   put y1 + (y0-y1)*s*s + (x0-x1) * s * c  into y
   put x,y into tPt
   if projPointLiesWithinEndPts(tPt,tLine)then
     return round(x),round(y)
   else return ""
end thePerpProjPt2



More information about the use-livecode mailing list