NAME
Math::PlanePath::PixelRings  pixellated concentric circles
SYNOPSIS
use Math::PlanePath::PixelRings;
my $path = Math::PlanePath::PixelRings>new;
my ($x, $y) = $path>n_to_xy (123);
DESCRIPTION
This path puts points on the pixels of concentric circles using the midpoint ellipse drawing algorithm.
6362616059 5
/ \
64 . 403938 . 58 4
/ / \ \
65 . 41 232221 37 . 57 3
/ / / \ \ \
66 . 42 24 10 9 8 20 36 . 56 2
 / / / \ \ \ 
67 43 25 11 . 3 . 7 19 35 55 1
    / \    
67 44 26 12 4 1 2 6 18 34 54 y=0
    \ /
68 45 27 13 . 5 . 17 33 53 80 1
 \ \ \ / / / 
69 . 46 28 141516 32 52 . 79 2
\ \ \ / / /
70 . 47 293031 51 . 78 3
\ \ / /
71 . 484950 . 77 4
\ /
7273747576 5
5 4 3 2 1 x=0 1 2 3 4 5
The way the algorithm works means the rings don't overlap. Each is 4 or 8 pixels longer than the preceding. If the ring follows the preceding tightly then it's 4 longer, like the 18 to 33 ring. If it goes wider then it's 8 longer, like the 54 to 80 ring. The average extra is 4*sqrt(2).
The rings are effectively partway between the diagonal like the DiamondSpiral and the corner like SquareSpiral. For example the 54 to 80 has a vertical part 54,55,56 then diagonal part 56,57,58,59. In bigger rings the verticals are intermingled with the diagonals. The number of vertical steps determine where it crosses the 45degree line, at r*sqrt(2) or thereabouts.
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.
$path = Math::PlanePath::PixelRings>new ()

Create and return a new path object.
($x,$y) = $path>n_to_xy ($n)

For
$n < 1
the return is an empty list, it being considered there are no negative points.The behaviour for fractional
$n
is not settled yet. A position on the line segment between the integer N's might make sense, but perhaps pointing 17.99 towards the "6" position to make a ring instead of towards the "18". $n = $path>xy_to_n ($x,$y)

Return an integer point number for coordinates
$x,$y
. Each integer N is considered the centre of a unit square and an$x,$y
within that square returns N.Not every point of the plane is covered (like those marked by a "." in the sample above). If
$x,$y
is not reached then the return isundef
.
SEE ALSO
Math::PlanePath, Math::PlanePath::Hypot, Math::PlanePath::MultipleRings
HOME PAGE
http://user42.tuxfamily.org/mathplanepath/index.html
LICENSE
Copyright 2010, 2011 Kevin Ryde
This file is part of MathPlanePath.
MathPlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
MathPlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with MathPlanePath. If not, see <http://www.gnu.org/licenses/>.