NAME

Math::PlanePath::SacksSpiral -- circular spiral, squaring each revolution

SYNOPSIS

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

DESCRIPTION

The Sacks spiral by Robert Sacks is an Archimedean spiral with points N placed on the spiral so the perfect squares fall on a line going to the right. Read more at

http://www.numberspiral.com

An Archimedean spiral means each loop is a constant distance from the preceding, in this case 1 unit. The polar coordinates are

R = sqrt(N)
theta = sqrt(N) * 2pi

which comes out roughly as

                18
      19   11        10  17
                 5
         
20  12  6   2
               0  1   4   9  16  25

               3
  21   13   7        8
                         15   24
                14
           22        23

The X,Y positions returned are fractional, except for the perfect squares on the right axis at X=0,1,2,3,etc spaced 1 apart. Other points are a little further apart.

The arms going to the right like 5,10,17,etc or 8,15,24,etc are constant offsets from the perfect squares, ie. s^2 + c for positive or negative integer c. To the left the central arm 2,6,12,20,etc is the pronic numbers s^2 + s, half way between the successive perfect squares. Other arms going to the left are offsets from that, ie. s^2 + s + c for integer c.

Euler's quadratic s^2+s+41 is one such arm going left. Low values loop around a few times before straightening out at about y=-127. This quadratic has relatively many primes and in a plot of the primes on the spiral it can be seen standing out from its surrounds.

Plotting various quadratic sequences of points can form attractive patterns. For example the triangular numbers s*(s+1)/2 come out as spiral arcs going clockwise and counter-clockwise.

FUNCTIONS

$path = Math::PlanePath::SacksSpiral->new ()

Create and return a new path object.

($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 spiral in between the integer points.

For $n < 0 the return is an empty list, it being considered there are no negative points in the spiral.

$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 spiral 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::PyramidRows Math::PlanePath::VogelFloret

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