1Math::PlanePath::SquareUAsremrs(C3o)ntributed Perl DocumMeanttha:t:iPolnanePath::SquareArms(3)
2
3
4

NAME

6       Math::PlanePath::SquareArms -- four spiral arms
7

SYNOPSIS

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

DESCRIPTION

14       This path follows four spiral arms, each advancing successively,
15
16                       ...--33--29                 3
17                                 |
18            26--22--18--14--10  25                 2
19             |               |   |
20            30  11-- 7-- 3   6  21                 1
21             |   |           |   |
22           ...  15   4   1   2  17  ...        <- Y=0
23                 |   |   |       |   |
24                19   8   5-- 9--13  32            -1
25                 |   |               |
26                23  12--16--20--24--28            -2
27                 |
28                27--31--...                       -3
29
30             ^   ^   ^   ^   ^   ^   ^
31            -3  -2  -1  X=0  1   2   3 ...
32
33       Each arm is quadratic, with each loop 128 longer than the preceding.
34       The perfect squares fall in eight straight lines 4, with the even
35       squares on the X and Y axes and the odd squares on the diagonals X=Y
36       and X=-Y.
37
38       Some novel straight lines arise from numbers which are a repdigit in
39       one or more bases (Sloane's A167782).  "111" in various bases falls on
40       straight lines.  Numbers "[16][16][16]" in bases 17,19,21,etc are a
41       horizontal at Y=3 because they're perfect squares, and "[64][64][64]"
42       in base 65,66,etc go a vertically downwards from X=12,Y=-266 similarly
43       because they're squares.
44
45       Each arm is N=4*k+rem for a remainder rem=0,1,2,3, so sequences related
46       to multiples of 4 or with a modulo 4 pattern may fall on particular
47       arms.
48

FUNCTIONS

50       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
51       classes.
52
53       "$path = Math::PlanePath::SquareArms->new ()"
54           Create and return a new path object.
55
56       "($x,$y) = $path->n_to_xy ($n)"
57           Return the X,Y coordinates of point number $n on the path.  For "$n
58           < 1" the return is an empty list, as the path starts at 1.
59
60           Fractional $n gives a point on the line between $n and "$n+4", that
61           "$n+4" being the next point on the same spiralling arm.  This is
62           probably of limited use, but arises fairly naturally from the
63           calculation.
64
65   Descriptive Methods
66       "$arms = $path->arms_count()"
67           Return 4.
68

FORMULAS

70   Rectangle N Range
71       Within a square X=-d...+d, and Y=-d...+d the biggest N is the end of
72       the N=5 arm in that square, which is N=9, 25, 49, 81, etc, (2d+1)^2, in
73       successive corners of the square.  So for a rectangle find a
74       surrounding d square,
75
76           d = max(abs(x1),abs(y1),abs(x2),abs(y2))
77
78       from which
79
80           Nmax = (2*d+1)^2
81                = (4*d + 4)*d + 1
82
83       This can be used for a minimum too by finding the smallest d covered by
84       the rectangle.
85
86           dlo = max (0,
87                      min(abs(y1),abs(y2)) if x=0 not covered
88                      min(abs(x1),abs(x2)) if y=0 not covered
89                     )
90
91       from which the maximum of the preceding dlo-1 square,
92
93           Nlo = /  1 if dlo=0
94                 \  (2*(dlo-1)+1)^2 +1  if dlo!=0
95                     = (2*dlo - 1)^2
96                     = (4*dlo - 4)*dlo + 1
97
98       For a tighter maximum, horizontally N increases to the left or right of
99       the diagonal X=Y line (or X=Y+/-1 line), which means one end or the
100       other is the maximum.  Similar vertically N increases above or below
101       the off-diagonal X=-Y so the top or bottom is the maximum.  This means
102       for a rectangle the biggest N is at one of the four corners,
103
104           Nhi = max (xy_to_n (x1,y1),
105                      xy_to_n (x1,y2),
106                      xy_to_n (x2,y1),
107                      xy_to_n (x2,y2))
108
109       The current code uses a dlo for Nlo and the corners for Nhi, which
110       means the high is exact but the low is not.
111

SEE ALSO

113       Math::PlanePath, Math::PlanePath::DiamondArms,
114       Math::PlanePath::HexArms, Math::PlanePath::SquareSpiral
115

HOME PAGE

117       <http://user42.tuxfamily.org/math-planepath/index.html>
118

LICENSE

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