geometry-challenged

Graham Samuel livfoss at blueyonder.co.uk
Sat Jan 24 19:17:13 EST 2004


On  wrote: Sat, 24 Jan 2004 13:26:05 -0800, Richard Gaskin 
<ambassador at fourthworld.com> wrote:
>
>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.
>

So, does your hint mean to say that the buttons in your diagram are 
always rectangles, or can they be polygons of arbitrary complexity? 
If only rectangles then I think it can be done fairly simply. To 
notate your diagram a bit differently:

>
>     -----------------
>    |                 |
>    |         A       |
>    |         |\      |
>     ---------g-h-----
>              |  \
>              |   \
>            --i----j---------
>           |  |     \        |
>           |  B----- C       |
>           |                 |
>            -----------------

i.e there's a right angled triangle ABC. You know all the coordinates 
of A, B and C already, plus we know the rects of the buttons. Thus we 
know the vertical distance A-g, and we also know the vertical 
distance A-B: then the proportion between the horizontal distance g-h 
and the horizontal distance B-C is the same as the (known) proportion 
A-g to A-B, which means you can find the position of h (the top 
intersection point) as needed. A similar calculation relating to the 
the triangle Aij means that you can get at point j. I'm sorry I 
haven't done this as a script but it's very late here in London...

Something similar could be done for circles but it would involve more 
real trig.

HTH - and I hope I'm right!

Graham

-- 
-------------------------------------------------------------------
          Graham Samuel / The Living Fossil Co. / UK & France


More information about the use-livecode mailing list