Hello, I am using Squeak-3.9-final-7067.image on win-xp. I create a polygon using: p := PolygonMorph new. p vertices: {0@0. 0@200. 200@200} color: Color black borderWidth: 2 borderColor: Color green. My original goal is to check if a line segment L is completely contained within this polygon p. Since the System browser shows that PolygonMorph has an intersects: aRectangle message, I thought I would create a rectangle with the original and corner as the end points of L and use it to query intersects. However any attempt to use the intersects: aRectangle method in PolygonMorph, e.g. r := Rectangle new. r setOrigin: 150@0 corner: 175@25. p intersects: r returns a message not understood. Am I doing something fundamentally wrong ? I can probably work around, but I would like to know why a method documented in the system browser does not work as expected. thanks, sgh _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hello, I am using Squeak-3.9-final-7067.image on win-xp. I create a polygon using: p := PolygonMorph new. p vertices: {0@0. 0@200. 200@200} color: Color black borderWidth: 2 borderColor: Color green. My original goal is to check if a line segment L is completely contained within this polygon p. Since the System browser shows that PolygonMorph has an intersects: aRectangle message, I thought I would create a rectangle with the original and corner as the end points of L and use it to query intersects. However any attempt to use the intersects: aRectangle method in PolygonMorph, e.g. r := Rectangle new. r setOrigin: 150@0 corner: 175@25. p intersects: r returns a message not understood. Am I doing something fundamentally wrong ? I can probably work around, but I would like to know why a method documented in the system browser does not work as expected. thanks, sgh _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
>>r := Rectangle new.
>>r setOrigin: 150@0 corner: 175@25. >>p intersects: r >>returns a message not understood. >> >>Am I doing something fundamentally wrong ? Yes you are. a rectangle is a polygon indeed. However, a PolygonMorph is a BorderedMorph, NOT a RectangleMorph. If you look for implementers of #intersects: , you will get only RectangleMorph. PolygonMorph DOES NOT IMPLEMENT #intersects. So the system does indeed NOT UNDERSTAND the message. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by S Hangal
PolygonMorph intersection
Hi Sudheendra Hangal, You have actually found a very good bug. In investigating I found that the method for Polygon did not exist in 3.8. The author of the version in 3.9 is nk 4/27/2003 16:15 PolygonMorph intersects: {geometry} nk is Ned Konz who created the connector package. In building the 3.9 release the release team added pieces of the the Connectors package. And while they did as best they could they missed a piece. The PolygonMorph>>intersects: methods calls super intersects: . None of the classes above PolygonMorph defines the intersects: method. Thus the error message. Simply finding the bug make you a winner in what I call the Game of Mantis. see: http://wiki.squeak.org/squeak/5915 Game of Mantis The best place for this info would be to start a Mantis report. (You can get a mantis acct freely and easily). A good place to start is: http://bugs.squeak.org/my_view_page.php Mantis provides a patient persistent way to focus on an issue. I use it to accumulate data on a problem until a solution can be found. It provides a place to: * alert the community to a problem; * accumulate facts and clues from the analysis; * publish preposed solutions and get feedback; * get solutions harvested and included into the main stream. The above is from: http://wiki.squeak.org/squeak/5912 Mantis FAQ and Tips Again thanks for your sharp eyes and easy to follow recipe for the bug. Yours in curiosity and service, --Jerome Peace *** > > > > [Newbies] Fwd: PolygonMorph intersection > Sudheendra Hangal hangal at cs.stanford.edu > Wed May 2 11:06:56 UTC 2007 > > Hello, > I am using Squeak-3.9-final-7067.image on win-xp. > > I create a polygon using: > p := PolygonMorph new. > p vertices: {0 at 0. 0 at 200. 200 at 200} color: > black borderWidth: 2 > borderColor: Color green. > > My original goal is to check if a line segment L is > completely contained > within this polygon p. Since the System browser shows > that PolygonMorph has > an intersects: aRectangle message, I thought I would > create a rectangle with > the original and corner as the end points of L and use > it to query > intersects. > > However any attempt to use the intersects: aRectangle > method in > PolygonMorph, e.g. > > r := Rectangle new. > r setOrigin: 150 at 0 corner: 175 at 25. > p intersects: r > returns a message not understood. > > Am I doing something fundamentally wrong ? > > I can probably work around, but I would like to > why a method documented > in > the system browser does not work as expected. > thanks, > > sgh *** __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by S Hangal
Thanks, Jerome - have filed the issue in Mantis. I'm looking for the easiest way to figure out if polygon A is contained inside polygon B. One way to do this is by checking if polygon A intersects any segments of B and any one of A's vertices lies inside B. is there a better way ? Thanks, -sgh
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Sounds good.
Depends how you define better. Faster code or shorter code? Maybe also add an optimistic rule first to fast up the false case: (polygonB bounds containsRect: polygonA bounds) ifFalse: [^false]. Of course, we can build degenerated examples which are hard to decide. To handle these, you also have to write better code. For example, beware of the case when a segment of A crosses a vertex of B. If inexact arithmetic is used, you can miss an intersection. Same apply for the second rule: case when a vertex of A lie on a segment of B. Take square A rotated by 45° and magnify by a factor (2 sqrt) to make sqaure B. A will fit into B, with each vertex of A lying on a segment of B. We can build more tricky cases where some edge of A and B are super-imposed, in part or whole... Nicolas S Hangal a écrit : > > Thanks, Jerome - have filed the issue in Mantis. > > I'm looking for the easiest way to figure out if polygon A is contained > inside polygon B. > > One way to do this is by checking if polygon A intersects any segments of B > and any one of A's vertices lies inside B. > is there a better way ? > > Thanks, > > -sgh > > > > Date: Wed, 2 May 2007 21:48:23 -0700 (PDT) > From: Jerome Peace <[hidden email] > <mailto:[hidden email]>> > Subject: [Newbies] Re: PolygonMorph intersection > To: " [hidden email] > <mailto:[hidden email]>" > <[hidden email] > <mailto:[hidden email]>> > Message-ID: < [hidden email] > <mailto:[hidden email]>> > Content-Type: text/plain; charset=iso-8859-1 > > PolygonMorph intersection > > > Hi Sudheendra Hangal, > > You have actually found a very good bug. > > In investigating I found that the method for Polygon > did not exist in 3.8. > > The author of the version in 3.9 is > > nk 4/27/2003 16:15 PolygonMorph intersects: {geometry} > > nk is Ned Konz who created the connector package. > > In building the 3.9 release the release team added > pieces of the the Connectors package. > And while they did as best they could they missed a > piece. > > The PolygonMorph>>intersects: methods calls super > intersects: . None of the classes above PolygonMorph > defines the intersects: method. Thus the error > message. > > Simply finding the bug make you a winner in what I > call the Game of Mantis. > > see: > http://wiki.squeak.org/squeak/5915 > Game of Mantis > > The best place for this info would be to start a > Mantis report. > (You can get a mantis acct freely and easily). > > A good place to start is: > > http://bugs.squeak.org/my_view_page.php > > Mantis provides a patient persistent way to focus on > an issue. > I use it to accumulate data on a problem until a > solution can be found. > It provides a place to: > > * alert the community to a problem; > * accumulate facts and clues from the analysis; > * publish preposed solutions and get feedback; > * get solutions harvested and included into the main > stream. > > The above is from: > http://wiki.squeak.org/squeak/5912 > Mantis FAQ and Tips > > Again thanks for your sharp eyes and easy to follow > recipe for the bug. > > Yours in curiosity and service, --Jerome Peace > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |