1Math::NumSeq::PlanePathUDseelrtaC(o3n)tributed Perl DocuMmaetnht:a:tNiuomnSeq::PlanePathDelta(3)
2
3
4

NAME

6       Math::NumSeq::PlanePathDelta -- sequence of changes and directions of
7       PlanePath coordinates
8

SYNOPSIS

10        use Math::NumSeq::PlanePathDelta;
11        my $seq = Math::NumSeq::PlanePathDelta->new
12                    (planepath => 'SquareSpiral',
13                     delta_type => 'dX');
14        my ($i, $value) = $seq->next;
15

DESCRIPTION

17       This is a tie-in to present coordinate changes and directions from a
18       "Math::PlanePath" module in the form of a NumSeq sequence.
19
20       The "delta_type" choices are
21
22           "dX"         change in X coordinate
23           "dY"         change in Y coordinate
24           "AbsdX"      abs(dX)
25           "AbsdY"      abs(dY)
26           "dSum"       change in X+Y, equals dX+dY
27           "dSumAbs"    change in abs(X)+abs(Y)
28           "dDiffXY"    change in X-Y, equals dX-dY
29           "dDiffYX"    change in Y-X, equals dY-dX
30           "dAbsDiff"   change in abs(X-Y)
31           "dRadius"    change in Radius sqrt(X^2+Y^2)
32           "dRSquared"  change in RSquared X^2+Y^2
33           "Dir4"       direction 0=East, 1=North, 2=West, 3=South
34           "TDir6"      triangular 0=E, 1=NE, 2=NW, 3=W, 4=SW, 5=SE
35
36       In each case the value at i is per "$path->n_to_dxdy($i)", being the
37       change from N=i to N=i+1, or from N=i to N=i+arms for paths with
38       multiple "arms" (thus following the arm).  i values start from the
39       usual "$path->n_start()".
40
41   AbsdX,AbsdY
42       If a path always steps NSEW by 1 then AbsdX and AbsdY behave as a
43       boolean indicating horizontal or vertical step,
44
45           NSEW steps by 1 gives
46
47           AbsdX = 0 vertical            AbsdY = 0 horizontal
48                   1 horizontal                  1 vertical
49
50       If a path includes diagonal steps by 1 then those diagonals are a non-
51       zero delta, so the indication is then
52
53           NSEW and diagonals steps by 1 gives
54
55           AbsdX = 0 vertical            AbsdY = 0 horizontal
56                   1 non-vertical                1 non-horizontal
57                     ie. horiz or diag             ie. vert or diag
58
59   dSum
60       "dSum" is the change in X+Y and is also simply dX+dY since
61
62           dSum = (Xnext+Ynext) - (X+Y)
63                = (Xnext-X) + (Ynext-Y)
64                = dX + dY
65
66       The sum X+Y counts anti-diagonals, as described in
67       Math::NumSeq::PlanePathCoord.  dSum is therefore a move between
68       diagonals, or 0 if a step stays within the same diagonal.
69
70                      \
71                       \  ^  dSum > 0      dSum = step dist to North-East
72                        \/
73                        /\
74           dSum < 0    v  \
75                           \
76
77   dSumAbs
78       "dSumAbs" is the change in the abs(X)+abs(Y) sum,
79
80           dSumAbs = (abs(Xnext)+abs(Ynext)) - (abs(X)+abs(Y))
81
82       As described in "SumAbs" in Math::NumSeq::PlanePathCoord, SumAbs is a
83       "Manhattan" or "taxi-cab" distance from the origin, or equivalently a
84       move between diamond-shaped rings.
85
86       For example "DiamondSpiral" follows a diamond shape ring around and so
87       has dSumAbs=0 until stepping out to each next diamond with dSumAbs=1.
88
89       A path might make a big X,Y jump which is only a small change in
90       SumAbs.  For example "PyramidRows" in its default step=2 from the end
91       of one row to the start of the next has dSumAbs=2.
92
93   dDiffXY and dDiffYX
94       "dDiffXY" is the change in DiffXY = X-Y, which is also simply dX-dY
95       since
96
97           dDiffXY = (Xnext-Ynext) - (X-Y)
98                   = (Xnext-X) - (Ynext-Y)
99                   = dX - dY
100
101       The difference X-Y counts diagonals downwards to the south-east as
102       described in "Sum and Diff" in Math::NumSeq::PlanePathCoord.  dDiffXY
103       is therefore movement between those diagonals, or 0 if a step stays
104       within the same diagonal.
105
106           dDiffXY < 0       /
107                         \  /             dDiffXY = step dist to South-East
108                          \/
109                          /\
110                         /  v
111                        /      dDiffXY > 0
112
113       "dDiffYX" is the negative of dDiffXY.  Whether X-Y or Y-X is desired
114       depends on which way you want to measure diagonals, or which way around
115       to have the sign for the changes.  dDiffYX is based on Y-X and so
116       counts diagonals upwards to the North-West.
117
118   dAbsDiff
119       "dAbsDiff" is the change in AbsDiff = abs(X-Y).  AbsDiff can be
120       interpreted geometrically as distance from the leading diagonal, as
121       described in "AbsDiff" in Math::NumSeq::PlanePathCoord.  dAbsDiff is
122       therefore movement closer to or further away from that leading
123       diagonal, measuring perpendicular to it.
124
125                       / X=Y line
126                      /
127                     /  ^
128                    /    \
129                   /      *  dAbsDiff move towards or away from X=Y line
130                 |/        \
131               --o--        v
132                /|
133               /
134
135       When an X,Y jumps from one side of the diagonal to the other dAbsDiff
136       is still the change in distance from the diagonal.  So for example if
137       X,Y is followed by the mirror point Y,X then dAbsDiff=0.  That sort of
138       thing happens for example in the "Diagonals" path when jumping from the
139       end of one run to the start of the next.  In the "Diagonals" case it's
140       a move just 1 further away from the X=Y centre line even though it's a
141       big jump in overall distance.
142
143   dRadius, dRSquared
144       "dRadius" and "dRSquared" are the change in the Radius and RSquared as
145       described in "Radius and RSquared" in Math::NumSeq::PlanePathCoord.
146
147           dRadius   = next_Radius   - Radius
148           dRSquared = next_RSquared - RSquared
149
150       dRadius can be interpreted geometrically as movement towards (negative
151       values) or away from (positive values) the origin, ignoring direction.
152
153       Notice that dRadius is not sqrt(dRSquared), since sqrt(n^2-t^2) != n-t
154       unless n or t is zero.  Here would mean a step either going to or
155       coming from the origin 0,0.
156
157   Dir4
158       "Dir4" is the curve step direction as an angle in the range 0 <= Dir4 <
159       4.  The cardinal directions E,N,W,S are 0,1,2,3.  Angles in between are
160       a fraction.
161
162           Dir4 = atan2(dY,dX)  scaled as range 0 <= Dir4 < 4
163
164           1.5   1   0.5
165               \ | /
166                \|/
167           2 ----o---- 0
168                /|\
169               / | \
170           2.5   3   3.5
171
172       If a row such as Y=-1,X>0 just below the X axis is visited then the
173       Dir4 approaches 4, without ever reaching it.  The
174       "$seq->value_maximum()" is 4 in this case, as a supremum.
175
176   TDir6
177       "TDir6" is the curve step direction 0 <= TDir6 < 6 taken in the
178       triangular style of "Triangular Lattice" in Math::PlanePath.  So
179       dX=1,dY=1 is taken to be 60 degrees which is TDir6=1.
180
181             2   1.5   1        TDir6
182                \ | /
183                 \|/
184             3 ---o--- 0
185                 /|\
186                / | \
187             4   4.5   5
188
189       Angles in between the six cardinal directions are fractions.  North is
190       1.5 and South is 4.5.
191
192       The direction angle is calculated as if dY was scaled by a factor
193       sqrt(3) to make the lattice into equilateral triangles, or equivalently
194       as a circle stretched vertically by sqrt(3) to become an ellipse.
195
196           TDir6 = atan2(dY*sqrt(3), dX)      in range 0 <= TDir6 < 6
197
198       Notice that angles on the axes dX=0 or dY=0 are not changed by the
199       sqrt(3) factor.  So TDir6 has ENWS 0, 1.5, 3, 4.5 which is steps of
200       1.5.  Verticals North and South normally don't occur in the triangular
201       lattice paths which go by unit steps, but TDir6 can be applied on any
202       path.
203
204       The sqrt(3) factor increases angles in the middle of the quadrants.
205       For example dX=1,dY=1 becomes TDir6=1 whereas a plain angle would be
206       only 45/360*6=0.75 in the same 0 to 6 scale.  The sqrt(3) is a
207       continuous scaling, so a plain angle and a TDir6 are a one-to-one
208       mapping.  As the direction progresses through the quadrant TDir6 grows
209       first faster and then slower than the plain angle.
210

FUNCTIONS

212       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
213       classes.
214
215       "$seq = Math::NumSeq::PlanePathDelta->new (key=>value,...)"
216           Create and return a new sequence object.  The options are
217
218               planepath          string, name of a PlanePath module
219               planepath_object   PlanePath object
220               delta_type         string, as described above
221
222           "planepath" can be either the module part such as "SquareSpiral" or
223           a full class name "Math::PlanePath::SquareSpiral".
224
225       "$value = $seq->ith($i)"
226           Return the change at N=$i in the PlanePath.
227
228       "$i = $seq->i_start()"
229           Return the first index $i in the sequence.  This is the position
230           "$seq->rewind()" returns to.
231
232           This is "$path->n_start()" from the PlanePath.
233

BUGS

235       Some path sequences don't have "oeis_anum()" and are not available
236       through Math::NumSeq::OEIS entry due to the path "n_start()" not
237       matching the OEIS "offset".  Paths with an "n_start" parameter have
238       suitable adjustments applied, but those without are omitted from the
239       Math::NumSeq::OEIS mechanism presently.
240

SEE ALSO

242       Math::NumSeq, Math::NumSeq::PlanePathCoord,
243       Math::NumSeq::PlanePathTurn, Math::NumSeq::PlanePathN
244
245       Math::PlanePath
246

HOME PAGE

248       <http://user42.tuxfamily.org/math-planepath/index.html>
249

LICENSE

251       Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020,
252       2021 Kevin Ryde
253
254       This file is part of Math-PlanePath.
255
256       Math-PlanePath is free software; you can redistribute it and/or modify
257       it under the terms of the GNU General Public License as published by
258       the Free Software Foundation; either version 3, or (at your option) any
259       later version.
260
261       Math-PlanePath is distributed in the hope that it will be useful, but
262       WITHOUT ANY WARRANTY; without even the implied warranty of
263       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
264       General Public License for more details.
265
266       You should have received a copy of the GNU General Public License along
267       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
268
269
270
271perl v5.34.0                      2022-01-21   Math::NumSeq::PlanePathDelta(3)
Impressum