NAME
Math::PlanePath::ToothpickSpiral  integer points in stairstep diagonal stripes
SYNOPSIS
use Math::PlanePath::ToothpickSpiral;
my $path = Math::PlanePath::ToothpickSpiral>new;
my ($x, $y) = $path>n_to_xy (123);
DESCRIPTION
This path is length=2 toothpicks placed in an anticlockwise spiral. A single new toothpick is added at an end of the preceding. Each is as close to the origin as possible without toothpicks overlapping. Ends may touch, but no overlapping.

32
  
54 1 ...
   
67 1011
  
89

The result is a stairstep diamond spiral starting vertically. As per the other toothpick paths the vertical toothpicks are "even" points X=Ymod2 and horizontal toothpicks "odd" points X!=Ymod2.
1918 ... 3
  
2120 1716 4544 2
  
2322 32 1514 4342 1
    
2524 54 1 1213 4041 < Y=0
   
2627 67 1011 3839 1
   
2829 89 3637 2
 
3031 3435 3
 
3233 4
^
4 3 2 1 X=0 1 2 3 4
N=1,15,45,etc on the X=Y leading diagonal and N=6,28,66,etc on the X=Y1 SouthWest diagonal are the hexagonal numbers k*(2k1). The odd hexagonals are to the NorthEast and the even hexagonals to the SouthWest.
The hexagonal numbers of the "second kind" which are k*(2k1) for k negative. They fall similarly on the X=Y1 NorthWest and X=Y SouthEast diagonals.
N Start
The default is to number points starting N=1 as shown above. An optional n_start
can give a different numbering of the same shape. For example to start at 0,
1817 n_start => 0
 
2019 1615
 
2221 21 1413
   
2423 43 0 1112
  
2526 56 910
  
2728 78

...
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
$path = Math::PlanePath::ToothpickSpiral>new ()
$path = Math::PlanePath::ToothpickSpiral>new (n_start => $n)

Create and return a new staircase path object.
Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
http://oeis.org/A059285 (etc)
n_start=1 (the default)
A014634 N on diagonal X=Y, odd hexagonals
A033567 N on diagonal NorthWest
A185438 N on diagonal SouthWest
A188135 N on diagonal SouthEast
n_start=0
A033587 N on diagonal X=Y
A014635 N on diagonal SouthWest, even hexagonals
A033585 N on diagonal SouthEast
SEE ALSO
Math::PlanePath, Math::PlanePath::Staircase, Math::PlanePath::DiamondSpiral
HOME PAGE
http://user42.tuxfamily.org/mathplanepath/index.html
LICENSE
Copyright 2013, 2014, 2015 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/>.