1Math::PlanePath::MPeaksU(s3e)r Contributed Perl DocumentaMtaitohn::PlanePath::MPeaks(3)
2
3
4
6 Math::PlanePath::MPeaks -- points in expanding M shape
7
9 use Math::PlanePath::MPeaks;
10 my $path = Math::PlanePath::MPeaks->new;
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This path puts points in layers of an "M" shape
15
16 41 49 7
17 40 42 48 50 6
18 39 22 43 47 28 51 5
19 38 21 23 44 46 27 29 52 4
20 37 20 9 24 45 26 13 30 53 3
21 36 19 8 10 25 12 14 31 54 2
22 35 18 7 2 11 4 15 32 55 1
23 34 17 6 1 3 5 16 33 56 <- Y=0
24
25 ^
26 -4 -3 -2 -1 X=0 1 2 3 4
27
28 N=1 to N=5 is the first "M" shape, then N=6 to N=16 on top of that,
29 etc. The centre goes half way down. Reckoning the N=1 to N=5 as layer
30 d=1 then
31
32 Xleft = -d
33 Xright = d
34 Ypeak = 2*d - 1
35 Ycentre = d - 1
36
37 Each "M" is 6 points longer than the preceding. The verticals are each
38 2 longer, and the centre diagonals each 1 longer. This step 6 is
39 similar to the "HexSpiral".
40
41 The octagonal numbers N=1,8,21,40,65,etc k*(3k-2) are a straight line
42 of slope 2 going up to the left. The octagonal numbers of the second
43 kind N=5,16,33,56,etc k*(3k+2) are along the X axis to the right.
44
45 N Start
46 The default is to number points starting N=1 as shown above. An
47 optional "n_start" can give a different start, in the same pattern.
48 For example to start at 0,
49
50 n_start => 0
51
52 40 48
53 39 41 47 49
54 38 21 42 46 27 50
55 37 20 22 43 45 26 28 51
56 36 19 8 23 44 25 12 29 52
57 35 18 7 9 24 11 13 30 53
58 34 17 6 1 10 3 14 31 54
59 33 16 5 0 2 4 15 32 55
60
62 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
63 classes.
64
65 "$path = Math::PlanePath::MPeaks->new ()"
66 Create and return a new path object.
67
68 "($x,$y) = $path->n_to_xy ($n)"
69 Return the X,Y coordinates of point number $n on the path.
70
71 For "$n < 0.5" the return is an empty list, it being considered
72 there are no negative points.
73
74 "$n = $path->xy_to_n ($x,$y)"
75 Return the point number for coordinates "$x,$y". $x and $y are
76 each rounded to the nearest integer which has the effect of
77 treating points as a squares of side 1, so the half-plane y>=-0.5
78 is entirely covered.
79
81 Entries in Sloane's Online Encyclopedia of Integer Sequences related to
82 this path include
83
84 <http://oeis.org/A045944> (etc)
85
86 n_start=1 (the default)
87 A045944 N on X axis >= 1, extra initial 0
88 being octagonal numbers second kind
89 A056106 N on Y axis, extra initial 1
90 A056109 N on X negative axis <= -1
91
92 n_start=0
93 A049450 N on Y axis, extra initial 0, 2*pentagonal
94
95 n_start=2
96 A027599 N on Y axis, extra initial 6,2
97
99 Math::PlanePath, Math::PlanePath::PyramidSides
100
102 <http://user42.tuxfamily.org/math-planepath/index.html>
103
105 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kevin Ryde
106
107 This file is part of Math-PlanePath.
108
109 Math-PlanePath is free software; you can redistribute it and/or modify
110 it under the terms of the GNU General Public License as published by
111 the Free Software Foundation; either version 3, or (at your option) any
112 later version.
113
114 Math-PlanePath is distributed in the hope that it will be useful, but
115 WITHOUT ANY WARRANTY; without even the implied warranty of
116 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
117 General Public License for more details.
118
119 You should have received a copy of the GNU General Public License along
120 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
121
122
123
124perl v5.30.0 2019-08-17 Math::PlanePath::MPeaks(3)