[Jprogramming] Polygon containment

R.E. Boss r.e.boss at planet.nl
Sat May 1 01:36:42 HKT 2010


Apparently it was too optimistic and too ambitious to try and use the inner
circle to exclude points. 
Bantchev's example and the spiral by Jacoby learned me so. 
But the outer circle still is of value, although you lose a few percent in
performance if all points are within that circle.

So we are left with

W2a=: 4 : 0
 'X Y'=. x ;&(j./&.|:) y
 t=. (X e.~ Y) -~ Y (>>./)&:| (,{.) X
 t=. (<.@(0.5&+) -:@(+/)@:(_1&^.)@(%_1&|.) X -/(0=t)#Y) (I.0=t)} 0>t
)

Here the simplification suggested by Jacobi is applied, delivering an
improvement in efficiency of some 30%, largely in space.


R.E. Boss


> Van: programming-bounces at jsoftware.com [mailto:programming-
> bounces at jsoftware.com] Namens R.E. Boss
> Onderwerp: Re: [Jprogramming] Polygon containment
> 
> Thanks for falsifying W2. I have to look into it.
> 
> 
> R.E. Boss
> 
> 
> > Van: programming-bounces at jsoftware.com [mailto:programming-
> > bounces at jsoftware.com] Namens Boyko Bantchev
> > Onderwerp: Re: [Jprogramming] Polygon containment
> >
> > On 26 April 2010 17:58, R.E. Boss <r.e.boss at planet.nl> wrote:
> > > ...
> > > 1. if 0 0 is not in the polygon, subtract (+/ % #)PLG from PLG and PTS
> >
> > It seems like we'll have to solve for 0 0 the problem that we are
> > trying to solve in the first place.
> >
> > > Some investigation has to be done whether W2 also works for more
> > uncommon
> > > polygons, like with intersections.
> >
> > It does not work even for lots of simple polygons:
> >    (4 2$_10 0 9 _5 _8 0 9 5) W2 0 0
> > 1
> > ----------------------------------------------------------------------




More information about the Programming mailing list