geometry-challenged

Jim Hurley jhurley at infostations.com
Sun Jan 25 11:45:56 EST 2004


>
>Message: 10
>Date: Sat, 24 Jan 2004 13:26:05 -0800
>From: Richard Gaskin <ambassador at fourthworld.com>
>Subject: geometry-challenged
>To: Rev Discussion List <use-revolution at lists.runrev.com>
>Message-ID: <BC3822ED.3BDAA%ambassador at fourthworld.com>
>Content-Type: text/plain; charset="US-ASCII"
>
>It seems I'm geometry-challenged today -- I know this should be simple, but
>I'm stumped:
>
>I can draw a line object from the loc of one object to the loc of another.
>But if I want to draw only in the space _between_ objects rather than
>intersect them, how do I get the points for the location where a line object
>would meet the edge of the other objects if drawn all the way to their
>centers, as indicated by the "X"s below:
>
>
>     -----------------
>    |                 |
>    |     button1     |
>    |         \       |
>     ----------X------
>                \
>                 \
>            ------X----------
>           |       \         |
>           |     button2     |
>           |                 |
>            -----------------
>
>
>Hint:  the diagram above with drawn with a tool I'm working on to make ASCII
>diagrams for email.  If we solve this I'll finish it next week and put it in
>RevNet.
>
>--
>  Richard Gaskin
>  Fourth World Media Corporation
>

Richard,

I'm not sure if this helps, but the function "intersection" below 
will return the intersection of any two lines. The first line is 
defined by its end points p1 and p2; the second line is defined by 
its two endpoints pp1, and pp1 (not the best notation.)

It is part of my Turtle Geometry tools. (Shameless plug: 
Indispensable tools for doing heavy graphics. From what I understand 
from Ro at the Developers' conference, Turtle Graphics may be 
incorporated in future editions of RR. This intersection function is 
not a traditional component of TG--so it may be included and it may 
not. In any event, it stands on its own.)

function intersection p1,p2,pp1,pp2
   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 pp1 into xp1
   put item 2 of pp1 into yp1
   put item 1 of pp2 into xp2
   put item 2 of pp2 into yp2
   if x1 = x2 or xp1 = xp2 then
     if x1 = x2 then
       return x1&comma&yp2 + (x1-xp2)*(yp2-yp1)/(xp2-xp1)
     else
       return xp2&comma& y2 + (xp1-x2)*(y2-y1)/(x2-x1)
     end if
   end if
   put yp2 - y2 + x2*(y2-y1)/(x2 - x1) - xp2*(yp2 - yp1)/(xp2 - xp1) 
into numerator
   put ((y2 - y1)/(x2 - x1) -(yp2 - yp1)/(xp2-xp1)) into denom
   put numerator / denom into x
   put y2 + (x-x2) *(y2-y1)/(x2-x1) into y
   return x & comma & y
end intersection


Jim


More information about the use-livecode mailing list