Math::PlanePath::MultipleRings -- rings of multiples
use Math::PlanePath::MultipleRings; my $path = Math::PlanePath::MultipleRings->new (step => 6); my ($x, $y) = $path->n_to_xy (123);
This path puts points on concentric rings. Each ring is "step" many points more then the previous, and the first is also "step" so each has a successively increasing multiple of that many points. For example with the default step==6,
24 23 25 22 10 26 11 9 21 ... 27 12 3 2 8 20 38 28 13 4 1 7 19 37 29 14 5 6 18 36 30 15 17 35 16 31 24 32 33
X,Y positions returned are fractional. The innermost ring like the 1,2,...,6 above has points 1 unit apart. Subsequent rings are either packed similarly or spread out to ensure the X axis points like 1,7,19,37 above are 1 unit apart. The latter happens for step <= 6 and for step >= 7 the rings are big enough to separate those X points.
The layout is similar to the spiral paths of corresponding step. For example step==6 is like the HexSpiral, only rounded out to circles instead of a hexagonal grid. Similarly step==4 the DiamondSpiral or step==8 the SquareSpiral.
The step parameter is similar to the PyramidRows with the rows stretched around circles, though PyramidRows starts from a 1-wide initial row and increases by the step, whereas for MultipleRings there's no initial.
$path = Math::PlanePath::MultipleRings->new (step => $integer)
Create and return a new path object.
The step parameter controls how many points are added in each circle. It defaults to 6 which is an arbitrary choice and the suggestion is to always pass in a desired count.
step
($x,$y) = $path->n_to_xy ($n)
Return the x,y coordinates of point number $n on the path.
$n
$n can be any value $n >= 0 and fractions give positions on the rings in between the integer points. For $n < 1 the return is an empty list since points begin at 1.
$n >= 0
$n < 1
Fractional $n currently ends up on the circle arc between the integer points. Would straight line chords between them be better, reflecting the unit spacing of the points? Neither seems particularly important.
$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 circle of diameter 1 and an $x,$y within that circle returns N.
$x,$y
The unit spacing of the points means those circles don't overlap, but they also don't cover the plane and if $x,$y is not within one then the return is undef.
undef
Math::PlanePath, Math::PlanePath::SacksSpiral, Math::PlanePath::TheodorusSpiral
http://user42.tuxfamily.org/math-planepath/index.html
Math-PlanePath is Copyright 2010 Kevin Ryde
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/>.
To install Math::PlanePath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::PlanePath
CPAN shell
perl -MCPAN -e shell install Math::PlanePath
For more information on module installation, please visit the detailed CPAN module installation guide.