I think that one should usually resist the temptation to introduce additional 
complexity into a program in order to speed it up a little in special cases, 
because it may turn out to be slower in some other cases, which is bad, and 
simplicity is lost, which is worse, and also bugs may be introduced, which is 
very bad.

The winding number program
   %&0j2p1@(+/)@:^.@(%_1&|.)
which is shorthand for 
   %&0j2p1@(+/)@:(1x1^.)@(%_1&|.)
can also be written
   -:@(+/)@:(_1&^.)@(%_1&|.)
thus avoiding introducing the trancendental constants 0j2p1 and 1x1.

But the still simpler version
   +/@:(1&^.)@(%_1&|.)
doesn't work because (1&^.), unlike (_1&^.), does not provide complex valued 
results! Perhaps (1&^.) should be implemented to mean (-:@_1&^) ?

The complex-number-into-integer rounding program
   <.@(0.5&+)@(9&o.) 
can for this purpose be replaced by
   <.@(0.5&+)
using the complex argument for (<.).

--- Den tirs 27/4/10 skrev R.E. Boss <[email protected]>:

> Fra: R.E. Boss <[email protected]>
> Emne: Re: [Jprogramming] Polygon containment
> Til: "'Programming forum'" <[email protected]>
> Dato: tirsdag 27. april 2010 10.09
> You are right, although it has not
> much to do with convexity.
> As I noticed, if most or all points are close to the edge
> of the polygon
> (ie. outside the inner and inside the outer circle), which
> in your (spiral)
> case is hard to avoid, then the preprocessing of W2 is
> superfluous and will
> (slightly) worsen the performance.
> 
> 
> R.E. Boss
> 
> 
> > Van: [email protected]
> [mailto:programming-
> > [email protected]]
> Namens Bo Jacoby
> > Onderwerp: Re: [Jprogramming] Polygon containment
> > 
> > Thank you.
> > 
> > I understanding that this optimization of the winding
> number algorithm
> > performs well on almost regular polygons, while it
> doesn't perform
> > substantially better on nonconvexe polygons like
> > 
> >   
> +/\(k...@-.,1,k=.(*0j1&^)@>:&i.)50
> > 
> > Am I right?
> > 
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to