Provided by: libmath-planepath-perl_113-1_all 

NAME
Math::PlanePath::MPeaks -- points in expanding M shape
SYNOPSIS
use Math::PlanePath::MPeaks;
my $path = Math::PlanePath::MPeaks->new;
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
This path puts points in layers of an "M" shape
41 49 7
40 42 48 50 6
39 22 43 47 28 51 5
38 21 23 44 46 27 29 52 4
37 20 9 24 45 26 13 30 53 3
36 19 8 10 25 12 14 31 54 2
35 18 7 2 11 4 15 32 55 1
34 17 6 1 3 5 16 33 56 <- Y=0
^
-4 -3 -2 -1 X=0 1 2 3 4
N=1 to N=5 is the first "M" shape, then N=6 to N=16 on top of that, etc. The centre goes half way down.
Reckoning the N=1 to N=5 as layer d=1 then
Xleft = -d
Xright = d
Ypeak = 2*d - 1
Ycentre = d - 1
Each "M" is 6 points longer than the preceding. The verticals are each 2 longer, and the centre
diagonals each 1 longer. This step 6 is similar to the "HexSpiral".
The octagonal numbers N=1,8,21,40,65,etc k*(3k-2) are a straight line of slope 2 going up to the left.
The octagonal numbers of the second kind N=5,16,33,56,etc k*(3k+2) are along the X axis to the right.
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
"$path = Math::PlanePath::MPeaks->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.
For "$n < 0.5" the return is an empty list, it being considered there are no negative points.
"$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 points as a squares of side 1, so the half-plane y>=-0.5 is entirely
covered.
OEIS
Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
<http://oeis.org/A045944> (etc)
A045944 N on X axis except initial 0, octagonal numbers second kind
A056106 N on Y axis, except initial 1
A056109 N on X negative axis, for X<=-1
SEE ALSO
Math::PlanePath, Math::PlanePath::PyramidSides
HOME PAGE
<http://user42.tuxfamily.org/math-planepath/index.html>
LICENSE
Copyright 2011, 2012, 2013 Kevin Ryde
This file is part of Math-PlanePath.
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/>.
perl v5.18.1 2013-12-07 Math::PlanePath::MPeaks(3pm)