I want to see if a circle hits a network of line segments. Alternatively, I
need to test for self-intersections in the nework of line segments. The
problem is to allow the user to drag nodes of the network but not let them
make the lines cross or drag nodes on top of each other. The circle is
small enough (it's just a small circle on top of the node (places where
segements meet) that it would be enough to test if the center hits a line
segment, which is why I initially tried to do it with hitTest.
I think the sweep algorithm is what I need. The book does seem to be good
at least in that one chapter.
Thanks to the person who recommended an AS 2.0 implementation of the
priority queue. I just looked and it is a better implementation than I
would have done. I am lazy and would have a tendency to implement only the
methods I need in a stupid inefficient manner, thus going against the whole
modularity/reusability goal of OO.
(On the other hand, that is what Extreme Programming gurus advocate -- they
say most code never gets reused and that you should code only to specs you
actually need for the specific problem you are solving. In my case, the
network of line segments has to be pretty small because it will be drawn and
manipulated by the user on the screen.)
Are there comprehensive graphics libraries for AS 2.0.? I am interested
only in 2d, but it would be cool to have a lib that does image processing
stuff along with 2d shape stuff. Of course 3d would be cool also, but my
guess is that fake 3d in Flash would be too slow to make it worthwhile to
have a really serious 3d library ala OpenGL. (Such a thing wasn't even
conceivable prior to Flash 8 because you need the bitmap classes to do
shading and lighting, let alone texture mapping.
BTW (off-topic): What is the standard comprehensive computer graphics text
these days? When I was in grad school, it was Foley-Van Dam (and some of my
friends worked for Andy Van Dam so they considered no other book) but I have
heard it is quite out-of-date.
Millie Niss
[EMAIL PROTECTED]
http://www.sporkworld.org
----- Original Message -----
From: "Glen Pike" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
Sent: Thursday, November 09, 2006 3:57 PM
Subject: Re: [Flashcoders] efficient line segment intersection algorithm?
Hi,
If the movie clips are circular, you may be faster using your own
maths...
Hit test will see if a point is in a clip, but you only want to see if
2 circles are touching.
Jobe Makar's book Macromedia Flash MX Game Design Demystified gives
this solution - called "Circle to Circle detection.
To summarise:
It you have circle_1 and circle_2
distance from circle_1 to circle_2 centre is found with Pythagoras.
Math.sqrt( x * x + y * y)
If distance <= (circle_1.radius - circle_2.radius) (the circles are
touching / overlapping)
Hope this helps.
Glen
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com