comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: intersecting polygons
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: intersecting polygons [message #29373] Mon, 18 February 2002 15:45
meron is currently offline  meron
Messages: 51
Registered: July 1995
Member
In article <e8de391d.0202171458.294f04@posting.google.com>, jvp10@psu.edu (Jonathan Pearce) writes:
> Hi,
>
> Does anybody know of, or have a routine that could take polygonal
> areas and find the common area between them? Consider the first
> polygon defined by the set of points x1,y1 where x1 and y1 are arrays.
> The second polygon is defined by the set of points x2 and y2. What I
> am looking for is the points where the lines given by x1,y1 and x2,y2
> intersect. Owing to limited time I am wondering if anybody has written
> such a routine, that would return a polygon describing the area common
> to both polygons.
>
I happen to have a set of routines which operate on 2D shapes and,
yes, there is one there that given two polygons will return the
vertices of their intersection, and there is another which will
calculate the area of any polygon.

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
Re: intersecting polygons [message #29374 is a reply to message #29373] Mon, 18 February 2002 14:40 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Have you tried IDLanROI? It has ContainsPoints method. It looks to me you
can call it twice setting ROI to one polygon, then another, and using the
remaining poilygon as data points to test. Then, once you have the results
from the two ContainsPoints operations, join tham to get the polygon
defining the intersection area.
Pavel

"Jonathan Pearce" <jvp10@psu.edu> wrote in message
news:e8de391d.0202171458.294f04@posting.google.com...
> Hi,
>
> Does anybody know of, or have a routine that could take polygonal
> areas and find the common area between them? Consider the first
> polygon defined by the set of points x1,y1 where x1 and y1 are arrays.
> The second polygon is defined by the set of points x2 and y2. What I
> am looking for is the points where the lines given by x1,y1 and x2,y2
> intersect. Owing to limited time I am wondering if anybody has written
> such a routine, that would return a polygon describing the area common
> to both polygons.
>
> I'd be most grateful for any responses!
>
> Jon Pearce.
Re: intersecting polygons [message #29386 is a reply to message #29374] Mon, 18 February 2002 04:03 Go to previous message
jvp10 is currently offline  jvp10
Messages: 4
Registered: February 2002
Junior Member
David,

It's elegant enough! Many thanks.

Jon Pearce.


David Fanning <david@dfanning.com> wrote in message news:<MPG.16da08ed83e1ed8a98980b@news.frii.com>...
> Jonathan Pearce (jvp10@psu.edu) writes:
>
>> Does anybody know of, or have a routine that could take polygonal
>> areas and find the common area between them? Consider the first
>> polygon defined by the set of points x1,y1 where x1 and y1 are arrays.
>> The second polygon is defined by the set of points x2 and y2. What I
>> am looking for is the points where the lines given by x1,y1 and x2,y2
>> intersect. Owing to limited time I am wondering if anybody has written
>> such a routine, that would return a polygon describing the area common
>> to both polygons.
>
> This probably falls under the category of the world's
> biggest hack, but I've used it to good effect.
>
> I use POLYFILLV with the two polygons to get a list
> of indices (or pixels) that belong to the two polygons.
> I then find the intersection of the two sets of pixels
> with the SetIntersection program (modified with some
> error checking in my real-world program), that you can
> find here:
>
> http://www.dfanning.com/tips/set_operations.html
>
> Knowing the pixel "size" allows me to calculate
> areas, etc. You can probably use IDLanROI for the
> same purpose. It's worked for me, although I don't
> make any claims as to its elegance. :-)
>
> Cheers,
>
> David
Re: intersecting polygons [message #29393 is a reply to message #29386] Sun, 17 February 2002 17:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jonathan Pearce (jvp10@psu.edu) writes:

> Does anybody know of, or have a routine that could take polygonal
> areas and find the common area between them? Consider the first
> polygon defined by the set of points x1,y1 where x1 and y1 are arrays.
> The second polygon is defined by the set of points x2 and y2. What I
> am looking for is the points where the lines given by x1,y1 and x2,y2
> intersect. Owing to limited time I am wondering if anybody has written
> such a routine, that would return a polygon describing the area common
> to both polygons.

This probably falls under the category of the world's
biggest hack, but I've used it to good effect.

I use POLYFILLV with the two polygons to get a list
of indices (or pixels) that belong to the two polygons.
I then find the intersection of the two sets of pixels
with the SetIntersection program (modified with some
error checking in my real-world program), that you can
find here:

http://www.dfanning.com/tips/set_operations.html

Knowing the pixel "size" allows me to calculate
areas, etc. You can probably use IDLanROI for the
same purpose. It's worked for me, although I don't
make any claims as to its elegance. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: debug IDL DLM in Visual C++
Next Topic: color and idl -rt

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:53:58 PDT 2025

Total time taken to generate the page: 0.00626 seconds