1Math::PlanePath::DiagonUaslesrAlCtoenrtnraitbiuntge(d3M)Paetrhl::DPolcaunmeePnattaht:i:oDniagonalsAlternating(3)
2
3
4

NAME

6       Math::PlanePath::DiagonalsAlternating -- points in diagonal stripes of
7       alternating directions
8

SYNOPSIS

10        use Math::PlanePath::DiagonalsAlternating;
11        my $path = Math::PlanePath::DiagonalsAlternating->new;
12        my ($x, $y) = $path->n_to_xy (123);
13

DESCRIPTION

15       This path follows successive diagonals going from the Y axis down to
16       the X axis and then back again,
17
18             7  |  29
19             6  |  28  30
20             5  |  16  27  31
21             4  |  15  17  26  ...
22             3  |   7  14  18  25
23             2  |   6   8  13  19  24
24             1  |   2   5   9  12  20  23
25           Y=0  |   1   3   4  10  11  21  22
26                +----------------------------
27                  X=0   1   2   3   4   5   6
28
29       The triangular numbers 1,3,6,10,etc k*(k+1)/2 are the start of each run
30       up or down alternately on the X axis and Y axis.  N=1,6,15,28,etc on
31       the Y axis (Y even) are the hexagonal numbers j*(2j-1).
32       N=3,10,21,36,etc on the X axis (X odd) are the hexagonal numbers of the
33       second kind j*(2j+1).
34
35   N Start
36       The default is to number points starting N=1 as shown above.  An
37       optional "n_start" can give a different start, in the same pattern.
38       For example to start at 0,
39
40           n_start => 0
41
42             4  |  14
43             3  |   6 13
44             2  |   5  7 12
45             1  |   1  4  8 11
46           Y=0  |   0  2  3  9 10
47                +-----------------
48                  X=0  1  2  3  4
49

FUNCTIONS

51       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
52       classes.
53
54       "$path = Math::PlanePath::DiagonalsAlternating->new ()"
55       "$path = Math::PlanePath::DiagonalsAlternating->new (n_start => $n)"
56           Create and return a new path object.
57
58       "($x,$y) = $path->n_to_xy ($n)"
59           Return the X,Y coordinates of point number $n on the path.
60
61           For "$n < 1" the return is an empty list, it being considered the
62           path begins at 1.
63

FORMULAS

65   Rectangle to N Range
66       Within each row increasing X is increasing N, and in each column
67       increasing Y is increasing N.  So in a rectangle the lower left corner
68       is the minimum N and the upper right is the maximum N.
69
70           |               N max
71           |     ----------+
72           |    |  ^       |
73           |    |  |       |
74           |    |   ---->  |
75           |    +----------
76           |   N min
77           +-------------------
78

OEIS

80       Entries in Sloane's Online Encyclopedia of Integer Sequences related to
81       this path include
82
83           <http://oeis.org/A131179> (etc)
84
85           n_start=1
86             A131179    N on X axis (extra initial 0)
87             A128918    N on Y axis (extra initial 1)
88             A001844    N on X=Y diagonal
89             A038722    permutation N at transpose Y,X
90
91           n_start=0
92             A003056    X+Y
93             A004247    X*Y
94             A049581    abs(X-Y)
95             A048147    X^2+Y^2
96             A004198    X bit-and Y
97             A003986    X bit-or Y
98             A003987    X bit-xor Y
99             A004197    min(X,Y)
100             A003984    max(X,Y)
101             A101080    HammingDist(X,Y)
102             A023531    dSum = dX+dY, being 1 at N=triangular+1 (and 0)
103             A046092    N on X=Y diagonal
104             A061579    permutation N at transpose Y,X
105
106             A056011    permutation N at points by Diagonals,direction=up order
107             A056023    permutation N at points by Diagonals,direction=down
108                runs alternately up and down, both are self-inverse
109
110       The coordinates such as A003056 X+Y are the same here as in the
111       Diagonals path.  "DiagonalsAlternating" transposes X,Y -> Y,X in every
112       second diagonal but forms such as X+Y are unchanged by swapping to Y+X.
113

SEE ALSO

115       Math::PlanePath, Math::PlanePath::Diagonals,
116       Math::PlanePath::DiagonalsOctant
117

HOME PAGE

119       <http://user42.tuxfamily.org/math-planepath/index.html>
120

LICENSE

122       Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kevin
123       Ryde
124
125       This file is part of Math-PlanePath.
126
127       Math-PlanePath is free software; you can redistribute it and/or modify
128       it under the terms of the GNU General Public License as published by
129       the Free Software Foundation; either version 3, or (at your option) any
130       later version.
131
132       Math-PlanePath is distributed in the hope that it will be useful, but
133       WITHOUT ANY WARRANTY; without even the implied warranty of
134       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
135       General Public License for more details.
136
137       You should have received a copy of the GNU General Public License along
138       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
139
140
141
142perl v5.30.0                      2019-M0a8t-h1:7:PlanePath::DiagonalsAlternating(3)
Impressum