Randal wrote
> In http://www.director-online.com/accessArticle.cfm?id=848 Gary notes that you
> can solve the collision of rects problem if you set the ink of the sprite to
> matte, and you should be able to rotate the skinny line.
>
> Seems like a nice, simple solution...
Unfortunately, I am not using any sprites (all the objects are drawn
directly to the stage via imaging lingo).
Anyway, I got it sorted (I think). Here's the code if anyone's interested:
-- returns TRUE or FALSE if the specified line intersects the specified Quad
on mLineIntersectsQuad (me, p1, p2, aQuad)
repeat with side = 1 to 4
-- get the line segment
p3 = aQuad[side]
if side < 4 then p4 = aQuad[side+1]
else p4 =aQuad[1]
if me._LineIntersects(p1,p2,p3,p4) then return 1
end repeat
end
on _LineIntersects (me, p1,p2,p3,p4)
denominator = (p4.locV-p3.locV)*(p2.locH-p1.loch) -
(p4.locH-p3.locH)*(p2.locV-p1.locV)
if denominator = 0 then return 0 -- lines a parallel
num1 = (p4.locH-p3.locH)*(p1.locV-p3.locV) -
(p4.locV-p3.locV)*(p1.locH-p3.locH)
num2 = (p2.locH-p1.locH)*(p1.locV-p3.locV) -
(p2.locV-p1.locV)*(p1.locH-p3.locH)
Ua = num1/float(denominator)
Ub = num2/float(denominator)
return (Ua >= 0 AND Ua < 1) AND (Ub >= 0 AND Ub < 1)
end
theres a test movie and some variations (such as getting the points of
intersection) at http://www.lingoworkshop.com/testzone/Geomtrytest4.html
Luke
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]