NAME
Math::PlanePath::AnvilSpiral  integer points around an "anvil" shape
SYNOPSIS
use Math::PlanePath::AnvilSpiral;
my $path = Math::PlanePath::AnvilSpiral>new;
my ($x, $y) = $path>n_to_xy (123);
DESCRIPTION
This path makes a spiral around an anvil style shape,
...7877767574 4
/
494847464544434241403938 73 3
\ / /
50 2120191817161514 37 72 2
\ \ / / /
51 22 5432 13 36 71 1
\ \ \ / / / /
52 23 6 1 12 35 70 < Y=0
/ / / \ \ \
53 24 7891011 34 69 1
/ / \ \
54 252627282930313233 68 2
/ \
55565758596061626364656667 3
^
6 5 4 3 2 1 X=0 1 2 3 4 5 6 7
The pentagonal numbers 1,5,12,22,etc, P(k) = (3k1)*k/2 fall alternately on the X axis X>0, and on the Y=1 horizontal X<0.
Those pentagonals are always composites, from the factorization shown, and as noted in "Step 3 Pentagonals" in Math::PlanePath::PyramidRows, the immediately preceding P(k)1 and P(k)2 are also composites. So plotting the primes on the spiral has a 3high horizontal blank line at Y=0,1,2 for positive X, and Y=1,2,3 for negative X (after the first few values).
Each loop around the spiral is 12 longer than the preceding. This is 4* more than the step=3 PyramidRows
so straight lines on a PyramidRows
like these pentagonals are also straight lines here, but split into two parts.
The outward diagonal excursions are similar to the OctagramSpiral
, but there's just 4 of them here where the OctagramSpiral
has 8. This is reflected in the loop step. The basic SquareSpiral
is step 8, but by taking 4 excursions here increases that to 12, and in the OctagramSpiral
8 excursions adds 8 to make step 16.
Wider
An optional wider
parameter makes the path wider by starting with a horizontal section of given width. For example
$path = Math::PlanePath::SquareSpiral>new (wider => 3);
gives
3332313029282726252423 ... 2
\ / /
34 111098765 22 51 1
\ \ / / /
35 12 1234 21 50 < Y=0
/ / \ \
36 1314151617181920 49 1
/ \
373839404142434445464748 2
^
6 5 4 3 2 1 X=0 1 2 3 4 5
The starting point 1 is shifted to the left by ceil(wider/2) places to keep the spiral centred on the origin X=0,Y=0. This is the same starting offset as the SquareSpiral
wider
.
Widening doesn't change the nature of the straight lines which arise, it just rotates them around. Each loop is still 12 longer than the previous, since the widening is essentially a constant amount in each loop.
N Start
The default is to number points starting N=1 as shown above. An optional n_start
can give a different start with the same shape. For example to start at 0,
n_start => 0
2019181716151413 ...
\ / /
21 4321 12 35
\ \ / / /
22 5 0 11 34
/ / \ \
23 678910 33
/ \
242526272829303132
The only effect is to push the N values around by a constant amount. It might help match coordinates with something else zerobased.
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
$path = Math::PlanePath::AnvilSpiral>new ()
$path = Math::PlanePath::AnvilSpiral>new (wider => $integer, n_start => $n)

Create and return a new anvil spiral object. An optional
wider
parameter widens the spiral path, it defaults to 0 which is no widening.
OEIS
Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
http://oeis.org/A033581 (etc)
default wider=0, n_start=1
A033570 N on X axis, alternate pentagonals (2n+1)*(3n+1)
A126587 N on Y axis
A136392 N on Y negative (n=Y+1)
A033568 N on X=Y diagonal, alternate second pents (2*n1)*(3*n1)
A085473 N on southeast diagonal
wider=0, n_start=0
A211014 N on X axis, 14gonal numbers of the second kind
A139267 N on Y axis, 2*octagonal
A049452 N on X negative, alternate pentagonals
A033580 N on Y negative, 4*pentagonals
A051866 N on X=Y diagonal, 14gonal numbers
A094159 N on northwest diagonal, 3*hexagonals
A049453 N on southwest diagonal, alternate second pentagonal
A195319 N on southeast diagonal, 3*second hexagonals
wider=1, n_start=0
A051866 N on X axis, 14gonal numbers
A049453 N on Y negative, alternate second pentagonal
A033569 N on northwest diagonal
A085473 N on southwest diagonal
A080859 N on Y negative
A033570 N on southeast diagonal
alternate pentagonals (2n+1)*(3n+1)
wider=2, n_start=1
A033581 N on Y axis (6*n^2) except for initial N=2
SEE ALSO
Math::PlanePath, Math::PlanePath::SquareSpiral, Math::PlanePath::OctagramSpiral, Math::PlanePath::HexSpiral
HOME PAGE
http://user42.tuxfamily.org/mathplanepath/index.html
LICENSE
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 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/>.