Provided by: libmath-planepath-perl_113-1_all
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. 63--62--61--60--59 5 / \ 64 . 40--39--38 . 58 4 / / \ \ 65 . 41 23--22--21 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 14--15--16 32 52 . 79 -2 \ \ \ / / / 70 . 47 29--30--31 51 . 78 -3 \ \ / / 71 . 48--49--50 . 77 -4 \ / 72--73--74--75--76 -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, for example N=18 to N=33. If it goes wider then it's 8 longer, for example N=54 to N=80 ring. The average extra is approximately 4*sqrt(2). The rings can be thought of as part-way between the diagonals like "DiamondSpiral" and the corners like "SquareSpiral". * ** ***** * * * * * * * * * * * * diagonal ring corner 5 points 6 points 9 points For example the N=54 to N=80 ring has a vertical part N=54,55,56 like a corner then a diagonal part N=56,57,58,59. In bigger rings the verticals are intermingled with the diagonals but the principle is the same. The number of vertical steps determines where it crosses the 45-degree line, which is at R*sqrt(2) but rounded according to the midpoint algorithm.
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for 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 unspecified as yet. "$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 is "undef".
SEE ALSO
Math::PlanePath, Math::PlanePath::Hypot, Math::PlanePath::MultipleRings
HOME PAGE
<http://user42.tuxfamily.org/math-planepath/index.html>
LICENSE
Copyright 2010, 2011, 2012, 2013 Kevin Ryde This file is part of Math-PlanePath. Math-PlanePath 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. Math-PlanePath 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 Math- PlanePath. If not, see <http://www.gnu.org/licenses/>.