in reply to Re: circular area in a coordinates grid (AoA)
in thread circular area in a coordinates grid (AoA)

very nice, thanks for the code and for the patience Marshall,

I noticed your code get some Use of uninitialized value in join or string if the circle goes outside of the AoA for high values of row.

I fixed it with a condition more in the nested for loop:

$aoa[$x][$y] = 'x' if ( (($x-$circle_x)**2 + ($y-$circle_y)**2 <= ($ci +rcle_radius**2) ) # and $x >=0 and $y >=0 ) + and $x >=0 and $y >=0 and $x <= $max )


There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^3: circular area in a coordinates grid (AoA)
by Marshall (Canon) on Mar 21, 2019 at 21:17 UTC
    Thanks for the correction! I guess there is a similar problem in the y direction. I like seeing bug reports like this because it means that somebody actually ran the code! I guess some adjustment of the loop conditional is also possible to not even consider points outside of the input array.

    I very seldom use $array[][] syntax because Perl is so cool at working with references to rows. I suppose some tricky splice() statement could be used, but my brain started hurting and I went for something straightforward. Glad to have been of help.

    Update: Here is modified version without extraneous prints and better control over loop condition: