Re: Finding a points inside polygon [message #32630 is a reply to message #32629] |
Thu, 24 October 2002 07:47   |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
Gunho Sohn wrote:
>
> Dear All,
>
> I have a problem to determine whether a point (x,y) is inside the polygon.
> Simply I've used IDLanROI::ContainsPoints method in my code. However, it
> seems to make a serious problem. Please, check this problem together. I used
> following polygons and point
>
> polygon vertices (vx,vy):
> vx=[35.859278 55.591451 155.00000 155.00000]
> vy=[0.00000000 0.00000000 19.279154 23.105984]
>
> point (x,y):
> x=122.87897 y=13.049367
>
> When I simply coded this as follows, it printes as 0 which means this point
> is located outside of polygon. But, it is not!
IDL> vx = [35.859278, 55.591451, 155.00000, 155.00000, 35.859278]
IDL> vy = [0.00000000, 0.00000000, 19.279154, 23.105984, 0.000000]
I added the extra point on the end, to close the polygon. ContainsPoint
doesn't need that closure, but the follow commands do:
IDL> plot,vx,vy
IDL> plots,[122.87897],[13.049367]
That's ambiguous - the point seems to be right on the edge.
IDL> plot,vx,vy,xrange=[122,123],yrange=[13,14]
IDL> plots,[122.87897],[13.049367],psym=1
That doesn't help; it's still ambiguous.
IDL> plot,vx,vy,xrange=[122.87,122.88],yrange=[13.04,13.05]
IDL> plots,[122.87897],[13.049367]
Finally! That looks to me like the point is slightly, but definitely,
outside of the polygon. ContainsPoint is apparantly correct.
|
|
|