1Math::PlanePath::CubicBUasseer(3C)ontributed Perl DocumeMnattaht:i:oPnlanePath::CubicBase(3)
2
3
4

NAME

6       Math::PlanePath::CubicBase -- replications in three directions
7

SYNOPSIS

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

DESCRIPTION

14       This is a pattern of replications in three directions 0, 120 and 240
15       degrees.
16
17                              18    19    26    27                      5
18                                 16    17    24    25                   4
19                        22    23    30    31                            3
20                           20    21    28    29                         2
21                  50    51    58    59     2     3    10    11          1
22                     48    49    56    57     0     1     8     9   <- Y=0
23            54    55    62    63     6     7    14    15               -1
24               52    53    60    61     4     5    12    13            -2
25                              34    35    42    43                     -3
26                                 32    33    40    41                  -4
27                        38    39    46    47                           -5
28                           36    37    44    45                        -6
29
30                                              ^
31           -11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6
32
33       The points are on a triangular grid by using every second integer X,Y,
34       as per "Triangular Lattice" in Math::PlanePath.  All points on that
35       triangular grid are visited.
36
37       The initial N=0,N=1 is replicated at +120 degrees.  Then that trapezoid
38       at +240 degrees
39
40           +-----------+                       +-----------+
41            \  2     3  \                       \  2     3  \
42             +-----------+                       \           \
43               \  0     1  \                       \  0     1  \
44                +-----------+             ---------  -----------+
45                                          \  6     7  \
46             replicate +120deg              \          \    rep +240deg
47                                             \  4     5 \
48                                              +----------+
49
50       Then that bow-tie N=0to7 is replicated at 0 degrees again.  Each
51       replication is 1/3 of the circle around, 0, 120, 240 degrees repeating.
52       The relative layout within a replication is unchanged.
53
54                             -----------------------
55                             \ 18    19    26    27 \
56                              \                       \
57                               \  16    17    24    25 \
58                      ----------              ----------
59                       \ 22    23    30    31 \
60                         \                      \
61                          \ 20    21    28    29  \
62                 --------- ------------ +----------- -----------
63                 \ 50    51    58    59  \  2     3  \ 10    11 \
64                   \                      +-----------+           \
65                    \ 48    49    56    57  \  0     1  \  8     9 \
66           ----------              --------- +-----------  ---------+
67           \ 54    55    62    63  \  6     7  \ 14    15  \
68            \                        \          \            \
69              \ 52    53    60    61  \  4     5 \  12    13  \
70               --------------          +----------+------------
71                             \ 34    35    42    43 \
72                              \                       \
73                               \  32    33    40    41 \
74                       ---------+            -----------
75                       \ 38    39    46    47 \
76                        \                       \
77                          \ 36    37    44    45 \
78                           -----------------------
79
80       The radial distance doubles on every second replication, so N=1 and N=2
81       are at 1 unit from the origin, then N=4 and N=8 at 2 units, then N=16
82       and N=32 at 4 units.  N=64 is not shown but is then at 8 units away
83       (X=8,Y=0).
84
85       This is similar to the "ImaginaryBase", but where that path repeats in
86       4 directions based on i=squareroot(-1), here it's 3 directions based on
87       w=cuberoot(1) = -1/2+i*sqrt(3)/2.
88
89   Radix
90       The "radix" parameter controls the "r" used to break N into X,Y.  For
91       example radix 4 gives 4x4 blocks, with r-1 replications of the
92       preceding level at each stage.
93
94              3         radix => 4              12    13    14    15
95              2                                     8     9    10    11
96              1                                        4     5     6     7
97            Y=0 ->                                        0     1     2     3
98             -1                     28    29    30    31
99             -2                        24    25    26    27
100             -3                           20    21    22    23
101             -4                              16    17    18    19
102             -5         44    45    46    47
103             ...           40    41    42    43
104                              36    37    38    39
105                                 32    33    34    35
106            60    61    62    63
107               56    57    58    59
108                  52    53    54    55
109                     48    49    50    51
110
111                                                          ^
112           -15-14-13-12-11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6
113
114       Notice the parts always replicate away from the origin, so the block
115       N=16 to N=31 is near the origin at X=-4, then N=32,48,64 are further
116       away.
117
118       In this layout the replications still mesh together perfectly and all
119       points on the triangular grid are visited.
120

FUNCTIONS

122       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
123       classes.
124
125       "$path = Math::PlanePath::CubicBase->new ()"
126       "$path = Math::PlanePath::CubicBase->new (radix => $r)"
127           Create and return a new path object.
128
129       "($x,$y) = $path->n_to_xy ($n)"
130           Return the X,Y coordinates of point number $n on the path.  Points
131           begin at 0 and if "$n < 0" then the return is an empty list.
132
133   Level Methods
134       "($n_lo, $n_hi) = $path->level_to_n_range($level)"
135           Return "(0, $radix**$level - 1)".
136

SEE ALSO

138       Math::PlanePath, Math::PlanePath::ImaginaryBase,
139       Math::PlanePath::ImaginaryHalf
140

HOME PAGE

142       <http://user42.tuxfamily.org/math-planepath/index.html>
143

LICENSE

145       Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin
146       Ryde
147
148       This file is part of Math-PlanePath.
149
150       Math-PlanePath is free software; you can redistribute it and/or modify
151       it under the terms of the GNU General Public License as published by
152       the Free Software Foundation; either version 3, or (at your option) any
153       later version.
154
155       Math-PlanePath is distributed in the hope that it will be useful, but
156       WITHOUT ANY WARRANTY; without even the implied warranty of
157       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
158       General Public License for more details.
159
160       You should have received a copy of the GNU General Public License along
161       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
162
163
164
165perl v5.36.0                      2022-07-22     Math::PlanePath::CubicBase(3)
Impressum