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: [email protected] [mailto:programming-
> [email protected]] Namens R.E. Boss
> Onderwerp: Re: [Jprogramming] Polygon containment
>
> Thanks for falsifying W2. I have to look into it.
>
>
> R.E. Boss
>
>
> > Van: [email protected] [mailto:programming-
> > [email protected]] Namens Boyko Bantchev
> > Onderwerp: Re: [Jprogramming] Polygon containment
> >
> > On 26 April 2010 17:58, R.E. Boss <[email protected]> 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
> > ----------------------------------------------------------------------
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm