Board index » delphi » Polygon inside polygon
Alex
Delphi Developer 
Tue, 13 Jul 2004 09:04:57 GMT

Alex
Delphi Developer 
Tue, 13 Jul 2004 09:04:57 GMT
Polygon inside polygon
Hi to all,
How can I know if one polygon is inside another polygon ? type begin // Now...how to know if Polygon2 is inside Polygon1 ??? .. If you test every point in Polygon2 against if that point is inside Polygon1 TIA 
Sue D. No
Delphi Developer 
Tue, 13 Jul 2004 23:30:07 GMT
Re:Polygon inside polygonIt the lines intersect, then by definition, one of the points of polygon2 must be outside polygon1, no? Or am I missing something? QuoteAlex S wrote: 
Jorge E. Pere
Delphi Developer 
Wed, 14 Jul 2004 01:08:43 GMT
Re:Polygon inside polygonThat definition only applies to regular polygons. I think he is talking about irregular polygons "Sue D. Nom" <su...@courthouse.com> wrote in message Quote> It the lines intersect, then by definition, one of the points of polygon2 
Jorge E. Pere
Delphi Developer 
Wed, 14 Jul 2004 01:56:55 GMT
Re:Polygon inside polygonCheck for line intersection. The following page my give you the clues that you need. Pay spetial atention http://astronomy.swin.edu.au/pbourke/geometry/lineline2d/ Jorge Quote"Alex S" <graph_developm...@yahoo.com> wrote in message Quote> Hi to all, 
Sue D. No
Delphi Developer 
Wed, 14 Jul 2004 03:12:35 GMT
Re:Polygon inside polygonIf by "irregular polygons" you mean those that have inclusions, or concave sides, or that have donut holes in them, then the solution is simple. For every point in polygon2, simply drop a line from the point to the x axis. If the line from the point crosses lines in polygon1 an odd number of times then the point is in polygon1, if it crosses an even number of polygon1 lines, it must be outside of polygon1. All you need is for one polygon2 point to fail this test to know that some part of it is outside polygon1. Quote"Jorge E. Perez" wrote: 
Alex
Delphi Developer 
Wed, 14 Jul 2004 04:26:21 GMT
Re:Polygon inside polygonThanks for the answer. Is simply to check if one polygon intersects another polygon. What I want to know if Polygon2 is completely inside polygon1 (no ++ Polygon clipping algorithms could be the sollution: If I obtain the ....but two poins against this:  Very difficult to implement a polygon clipping algorithm. Any other solluion for this ? Thanks "Jorge E. Perez" <jorg...@unm.edu> wrote in message news:3c519c80_1@dnews... Quote> Check for line intersection. 
Thérèse Hanque
Delphi Developer 
Wed, 14 Jul 2004 04:44:44 GMT
Re:Polygon inside polygonHi Alex, Quote> Polygon clipping algorithms could be the sollution: If I obtain the http://msdn.microsoft.com/library/enus/gdi/regions_7tf2.asp Thrse 
Thérèse Hanque
Delphi Developer 
Wed, 14 Jul 2004 04:40:13 GMT
Re:Polygon inside polygonHi Sue, Quote> For every point in polygon2, simply drop a line from the point to the x axis. possible to compute the coordinates of "every point" of the polygon, as there is an infinite number of them. What you can test: At least one vertex inside and no intersection of sides means polygon1 is entirely Thrse 
Sue D. No
Delphi Developer 
Wed, 14 Jul 2004 05:03:39 GMT
Re:Polygon inside polygonAll you need to do is test the vertices of the polygon in the manner I noted... all points not required... sorry for the confusion. There is one test that needs to be made. If a vertex of polygon2 falls onto a line PS: The dropping a line from the vertex to the xaxis works for all sorts of Quote"Thrse Hanquet" wrote: true. However, I would say that if one already has a generalized point in polygon routine, then it is not necessary to have a specialized polygon in polygon routine. 
Thérèse Hanque
Delphi Developer 
Wed, 14 Jul 2004 05:38:15 GMT
Re:Polygon inside polygonHi Sue, Quote> There is one test that needs to be made. If a vertex of polygon2 falls onto a still be parts of polygon2 outside of polygon1 if polygon1 is concave. For example think of a polygon with a shape of empty V. You may have a rectangle with its right side inside the right branch of the V and its left side inside the other branch, so all its vertices are inside, but still a part of its area may be outside the shape of the V. Quote> PS: The dropping a line from the vertex to the xaxis works for all sorts of ago (available on efg's site), only the line is drawn horizontally, not vertically. Thrse 
Thérèse Hanque
Delphi Developer 
Wed, 14 Jul 2004 05:40:51 GMT
Re:Polygon inside polygonHi Sue, Quote> There is one test that needs to be made. If a vertex of polygon2 falls onto a still be parts of polygon2 outside of polygon1 if polygon1 is concave. For example think of a polygon with a shape of empty V. You may have a rectangle with its right side inside the right branch of the V and its left side inside the other branch, so all its vertices are inside, but still a part of its area may be outside the shape of the V. Quote> PS: The dropping a line from the vertex to the xaxis works for all sorts of ago (available on efg's site), only the line is drawn horizontally, not vertically. Thrse P.S. Sorry if this is duplicated, at the moment my previous post seems lost. 
Sue D. No
Delphi Developer 
Wed, 14 Jul 2004 05:54:51 GMT
Re:Polygon inside polygonYou are indeed correct. A point test is insufficient Quote"Thrse Hanquet" wrote: 
DP
Delphi Developer 
Wed, 14 Jul 2004 05:50:50 GMT
Re:Polygon inside polygonHi , If you know OpenGL then you can you tesselator using AB_GEQ_TWO property to determine if there is any int{*word*114} and it will return you triangles. DPS Quote"Alex S" <graph_developm...@yahoo.com> wrote in message Quote> Thanks for the answer.  Hide quoted text   Show quoted text  Quote> > Check for line intersection. 
Alex
Delphi Developer 
Wed, 14 Jul 2004 08:18:11 GMT
Re:Polygon inside polygonHi, Thanks to all for your help! Quote> Did you try the CombineRegion GDI call? Quote> At least one vertex inside and no intersection of sides means polygon1 is intensively. Thanks a lot. Quote"Thrse Hanquet" <therese.hanq...@skynet.be> wrote in message Quote> Hi Alex, 
Loren Pecht
Delphi Developer 
Thu, 15 Jul 2004 01:24:09 GMT
Re:Polygon inside polygonOn Fri, 25 Jan 2002 13:12:35 0600, "Sue D. Nom" Quote<su...@courthouse.com> wrote: inside. Consider: +++++++++++++++++++++ I hope that didn't get too mangled by fonts. 
1. Segment inside polygon, and Segment inside cube.
2. Clipping Polygons by Polygons in Delphi
3. Polygons and Textured Polygons
4. is point inside the polygon
5. How can I detect if a point is inside a polygon (without regions)
6. Delphi4: Textured Polygons for Delphi Source needs a fixing