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

Home » Public Forums » archive » polygon intersection routine in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: polygon intersection routine in IDL [message #52678 is a reply to message #52545] Wed, 14 February 2007 10:07 Go to previous messageGo to previous message
mmeron is currently offline  mmeron
Messages: 44
Registered: October 2003
Member
In article <1171452966.005192.305170@a34g2000cwb.googlegroups.com>, "Weihua FANG" <weihua.fang@gmail.com> writes:
> It works fine now.
>
> Thank you
>
You're welcome. Take a look at the other routines with names starting
with SHAPE_ , they all deal with polygons.

>
>> In article <1171433274.480043.121...@q2g2000cwa.googlegroups.com>, "Weihu=
> a FANG" <weihua.f...@gmail.com> writes:
>>
>>
>>
>>> Hi, dear mati,
>>
>>> I tested your function by 2 samples. One returned the overlap polygon
>>> successfully. but the second one failed. is there anything wrong in my
>>> code?
>>
>>> thank you in advance.
>>
>>> pro test_polygon_overlap
>>
>>> shape1 =3D3D fltarr(2,4)
>>> shape2 =3D3D fltarr(2,4)
>>> shape1[0,0] =3D3D 0.1
>>> shape1[0,1] =3D3D 1.1
>>> shape1[0,2] =3D3D 1.2
>>> shape1[0,3] =3D3D 0.2
>>> shape1[1,0] =3D3D 0.2
>>> shape1[1,1] =3D3D 0.15
>>> shape1[1,2] =3D3D 1.1
>>> shape1[1,3] =3D3D 1.2
>>
>>> shape2[0,0] =3D3D 0.5
>>> shape2[0,1] =3D3D 1.5
>>> shape2[0,2] =3D3D 1.6
>>> shape2[0,3] =3D3D 0.4
>>> shape2[1,0] =3D3D 0.5
>>> shape2[1,1] =3D3D 0.6
>>> shape2[1,2] =3D3D 1.7
>>> shape2[1,3] =3D3D 1.5
>>
>>> shape3 =3D3D shape_overlap (shape1, shape2, exists =3D3D exs)
>>
>>> print, exs
>>
>>> shape1 =3D3D fltarr(2,17)
>>> shape1 [*,0] =3D3D [116.44991,41.441910]
>>> shape1 [*,1] =3D3D [116.57357,41.374821]
>>> shape1 [*,2] =3D3D [116.64723,41.312994]
>>> shape1 [*,3] =3D3D [116.57488,41.002544]
>>> shape1 [*,4] =3D3D [116.36967,40.928878]
>>> shape1 [*,5] =3D3D [116.16840,40.984128]
>>> shape1 [*,6] =3D3D [116.21576,41.053847]
>>> shape1 [*,7] =3D3D [116.06185,41.099889]
>>> shape1 [*,8] =3D3D [116.10263,41.168293]
>>> shape1 [*,9] =3D3D [116.13683,41.214334]
>>> shape1 [*,10] =3D3D [116.16577,41.264322]
>>> shape1 [*,11] =3D3D [116.18156,41.319572]
>>> shape1 [*,12] =3D3D [116.22891,41.344565]
>>> shape1 [*,13] =3D3D [116.31442,41.357720]
>>> shape1 [*,14] =3D3D [116.29337,41.387976]
>>> shape1 [*,15] =3D3D [116.34468,41.422178]
>>> shape1 [*,16] =3D3D [116.44991,41.441910]
>>
>>> shape2 =3D3D fltarr(2,6)
>>> shape2 [*,0] =3D3D [116.21839,41.528731]
>>> shape2 [*,1] =3D3D [116.61698,41.524784]
>>> shape2 [*,2] =3D3D [116.72748,41.141984]
>>> shape2 [*,3] =3D3D [116.30916,41.203810]
>>> shape2 [*,4] =3D3D [116.13552,41.289316]
>>> shape2 [*,5] =3D3D [116.21839,41.528731]
>>
>>> xrange =3D3D [116.06185 ,116.72748]
>>> yrange =3D3D [40.928879 ,41.528732]
>>
>>> plot, shape1[0,*], shape1[1,*], xrange =3D3D xrange , yrange =3D3D yran=
> ge
>>> oplot, shape2[0,*], shape2[1,*]
>>
>>> shape3=3D3D shape_overlap (shape1, shape2, exists =3D3D exs)
>>
>>> print, exs
>>
>>> end
>>
>> Well, thank you. I didn't use this routine for nearly a decade,
>> didn't notice that it has a bug. OK, go to line 72 of the routine,
>> the one which has a statement starting with
>>
>> if Shape_area....
>>
>> And replace it with
>>
>> if Shape_area(sec) lt 0 then sec =3D reverse(sec,2)
>>
>> Should work now, let me know if it doesn't
>>
>> Mati Meron | "When you argue with a fool,
>> m...@cars.uchicago.edu | chances are he is doing just the same"-=
> =D2=FE=B2=D8=B1=BB=D2=FD=D3=C3=CE=C4=D7=D6 -
>>
>> - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 -
>
>

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Writing to the IDLde
Next Topic: any objects for handling (program) state transitions

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

Current Time: Wed Oct 15 13:50:23 PDT 2025

Total time taken to generate the page: 1.27879 seconds