1Math::PlanePath::StaircUasseer(3C)ontributed Perl DocumeMnattaht:i:oPnlanePath::Staircase(3)
2
3
4

NAME

6       Math::PlanePath::Staircase -- integer points in stair-step diagonal
7       stripes
8

SYNOPSIS

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

DESCRIPTION

15       This path makes a staircase pattern down from the Y axis to the X,
16
17            8      29
18                    |
19            7      30---31
20                         |
21            6      16   32---33
22                    |         |
23            5      17---18   34---35
24                         |         |
25            4       7   19---20   36---37
26                    |         |         |
27            3       8--- 9   21---22   38---39
28                         |         |         |
29            2       2   10---11   23---24   40...
30                    |         |         |
31            1       3--- 4   12---13   25---26
32                         |         |         |
33           Y=0 ->   1    5--- 6   14---15   27---28
34
35                    ^
36                   X=0   1    2    3    4    5    6
37
38       The 1,6,15,28,etc along the X axis at the end of each run are the
39       hexagonal numbers k*(2*k-1).  The diagonal 3,10,21,36,etc up from
40       X=0,Y=1 is the second hexagonal numbers k*(2*k+1), formed by extending
41       the hexagonal numbers to negative k.  The two together are the
42       triangular numbers k*(k+1)/2.
43
44       Legendre's prime generating polynomial 2*k^2+29 bounces around for some
45       low values then makes a steep diagonal upwards from X=19,Y=1, at a
46       slope 3 up for 1 across, but only 2 of each 3 drawn.
47
48   N Start
49       The default is to number points starting N=1 as shown above.  An
50       optional "n_start" can give a different start, in the same pattern.
51       For example to start at 0,
52
53           n_start => 0
54
55           28
56           29 30
57           15 31 32
58           16 17 33 34
59            6 18 19 35 36
60            7  8 20 21 37 38
61            1  9 10 22 23 ....
62            2  3 11 12 24 25
63            0  4  5 13 14 26 27
64

FUNCTIONS

66       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
67       classes.
68
69       "$path = Math::PlanePath::Staircase->new ()"
70       "$path = Math::PlanePath::AztecDiamondRings->new (n_start => $n)"
71           Create and return a new staircase path object.
72
73       "$n = $path->xy_to_n ($x,$y)"
74           Return the point number for coordinates "$x,$y".  $x and $y are
75           rounded to the nearest integers, which has the effect of treating
76           each point $n as a square of side 1, so the quadrant x>=-0.5,
77           y>=-0.5 is covered.
78
79       "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)"
80           The returned range is exact, meaning $n_lo and $n_hi are the
81           smallest and biggest in the rectangle.
82

FORMULAS

84   Rectangle to N Range
85       Within each row increasing X is increasing N, and in each column
86       increasing Y is increasing pairs of N.  Thus for "rect_to_n_range()"
87       the lower left corner vertical pair is the minimum N and the upper
88       right vertical pair is the maximum N.
89
90       A given X,Y is the larger of a vertical pair when ((X^Y)&1)==1.  If
91       that happens at the lower left corner then it's X,Y+1 which is the
92       smaller N, as long as Y+1 is in the rectangle.  Conversely at the top
93       right if ((X^Y)&1)==0 then it's X,Y-1 which is the bigger N, again as
94       long as Y-1 is in the rectangle.
95

OEIS

97       Entries in Sloane's Online Encyclopedia of Integer Sequences related to
98       this path include
99
100           <http://oeis.org/A084849> (etc)
101
102           n_start=1 (the default)
103             A084849    N on diagonal X=Y
104             A210521    permutation N by diagonals, upwards
105             A199855      inverse
106
107           n_start=0
108             A014105    N on diagonal X=Y, second hexagonal numbers
109
110           n_start=2
111             A128918    N on X axis, except initial 1,1
112             A096376    N on diagonal X=Y
113

SEE ALSO

115       Math::PlanePath, Math::PlanePath::Diagonals, Math::PlanePath::Corner,
116       Math::PlanePath::ToothpickSpiral
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, 2019,
123       2020, 2021 Kevin 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.32.1                      2021-01-27     Math::PlanePath::Staircase(3)
Impressum