NAME

Math::PlanePath::MultipleRings -- rings of multiples

SYNOPSIS

use Math::PlanePath::MultipleRings;
my $path = Math::PlanePath::MultipleRings->new (step => 6);
my ($x, $y) = $path->n_to_xy (123);

DESCRIPTION

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.

The starting radial 1,7,19,37 etc for step==6 is 6*k*(k-1)/2 + 1 (for k=1 upwards) and in general it's step*k*(k-1)/2 + 1 which is basically a step multiple of the triangular numbers. Straight line radials further around have arise from adding multiples of k, so for example for step==6 above the line 3,11,25 is 6*k*(k-1)/2 + 1 + 2*k. Multiples of k bigger than the step give lines in between those of the innermost ring.

Step 3 Pentagonals

For step==3 the pentagonal numbers 1,5,12,22,etc, P(k) = (3k-1)*k/2, are a radial going up to the left, and the second pentagonal numbers 2,7,15,26, S(k) = (3k+1)*k/2 are a radial going down to the left, respectively 1/3 and 2/3 the way around the circles.

As described in "Step 3 Pentagonals" in Math::PlanePath::PyramidRows, those numbers and the preceding P(k)-1, P(k)-2, and S(k)-1, S(k)-2 are all composites, so plotting the primes on a step==3 MultipleRings has these values as two radial gaps where there's no primes.

FUNCTIONS

$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.

($x,$y) = $path->n_to_xy ($n)

Return the x,y coordinates of point number $n on the path.

$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.

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.

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.

SEE ALSO

Math::PlanePath, Math::PlanePath::SacksSpiral, Math::PlanePath::TheodorusSpiral

HOME PAGE

http://user42.tuxfamily.org/math-planepath/index.html

LICENSE

Math-PlanePath is Copyright 2010, 2011 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/>.