NAME
Math::PlanePath::HeptSpiralSkewed  integer points around a skewed seven sided spiral
SYNOPSIS
use Math::PlanePath::HeptSpiralSkewed;
my $path = Math::PlanePath::HeptSpiralSkewed>new;
my ($x, $y) = $path>n_to_xy (123);
DESCRIPTION
This path makes a sevensided spiral by cutting one corner of a square
31302928 3
 \
32 141312 27 2
  \ \
33 15 43 11 26 1
   \ \ \
34 16 5 12 10 25 < Y=0
    
35 17 6789 24 1
  
36 181920212223 2

3738394041... 3
^
3 2 1 X=0 1 2 3
The path is as if around a heptagon, with the left and bottom here as two sides of the heptagon straightened out, and the flat top here skewed across to fit a square grid.
N Start
The default is to number points starting N=1 as shown above. An optional n_start
can give a different start, in the same pattern. For example to start at 0,
30 29 28 27 n_start => 0
31 13 12 11 26
32 14 3 2 10 25
33 15 4 0 1 9 24
34 16 5 6 7 8 23
35 17 18 19 20 21 22
36 37 38 39 40 ...
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
$path = Math::PlanePath::HeptSpiralSkewed>new ()
$path = Math::PlanePath::HeptSpiralSkewed>new (n_start => $n)

Create and return a new path object.
$n = $path>xy_to_n ($x,$y)

Return the point number for coordinates
$x,$y
.$x
and$y
are each rounded to the nearest integer, which has the effect of treating each N in the path as centred in a square of side 1, so the entire plane is covered.
FORMULAS
N to X,Y
It's convenient to work in terms of Nstart=0 and to take each loop as beginning on the SouthWest diagonal,
top length = d
30292827
 \
31 26 diagonal length = d
left  \
length 32 25
= 2*d  \
33 0 24
  right
34 . 23 length = d1
 
35 171819202122

. bottom length = 2*d1
The SW diagonal is N=0,5,17,36,etc which is
N = (7d11)*d/2 + 2 # starting d=1 first loop
This can be inverted to get d from N
d = floor( (sqrt(56*N+9)+11)/14 )
The side lengths are as shown above. The first loop is d=1 and for it the "right" vertical length is zero, so no such side on that first loop 0 <= N < 5.
OEIS
Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
http://oeis.org/A192136 (etc)
n_start=1
A140065 N on Y axis
n_start=0
A001106 N on X axis, 9gonal numbers
A218471 N on Y axis
A022265 N on X negative axis
A179986 N on Y negative axis, second 9gonals
A195023 N on X=Y diagonal
A022264 N on NorthWest diagonal
A186029 N on SouthWest diagonal
A024966 N on SouthEast diagonal
SEE ALSO
Math::PlanePath, Math::PlanePath::SquareSpiral, Math::PlanePath::PentSpiralSkewed, Math::PlanePath::HexSpiralSkewed
HOME PAGE
http://user42.tuxfamily.org/mathplanepath/index.html
LICENSE
Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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/>.