PlanePath/PeanoCurve.pm

filter: Statementstmt 88.6% 187 / 211 Branchbran 60.5% 46 / 76 Conditioncond 82.3% 28 / 34 MC/DCmcdc 55.5% 10 / 18 Subroutinesub 73.0% 19 / 26 Podpod 100% 7 / 7 totaltotal 79.8% 297 / 372 CC 52 SCAR 23.2
CC
52
Cov
81%
rect_to_n_range
22.0
_xykk_to_n
14.0
xy_to_n
6.9
CRAP 10.2
« PlanePath/QuintetReplicate.pm ↑ Summary PlanePath/QuintetCurve.pm »
1 # Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde
2  
3 # This file is part of Math-PlanePath.
4 #
5 # Math-PlanePath is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Math-PlanePath is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
17  
18  
19 # cf
20 #
21 # http://www.cut-the-knot.org/Curriculum/Geometry/PeanoComplete.shtml
22 # applet, directions in 9 sub-parts
23 #
24 # math-image --path=PeanoCurve,radix=5 --all --output=numbers
25 # math-image --path=PeanoCurve,radix=5 --lines
26 #
27 # -----------
28 # Peano:
29 # T = 0.a1 a2 a3 a4 ...
30 # x y x y
31 #
32 # X = 0.b1 b2 ...
33 # a1 a3.k(a2)
34 #
35 # Y = 0.c1 c2 ...
36 # a2.k(a1) a4.k(a1,a3)
37 #
38 # b1=a1
39 # c1 = a2 comp(a1)
40 # b2 = a3 comp(a2)
41 # c2 = a4 comp(a1+a3)
42 #
43 # bn = a[2n-1] comp a2+a4+...+a[2n-2]
44 # cn = a[2n] comp a1+a3+...+a[2n-1]
45 #
46 # Brouwer(?) no continuous one-to-one between R and RxR, so line and plane
47 # are distinguished.
48 #
49  
50  
51 package Math::PlanePath::PeanoCurve;
52 5 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 #use List::Util 'max';
55 5 *max = \&Math::PlanePath::_max;
56  
57 5 ▶use vars '$VERSION', '@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
58 5 $VERSION = 128;
59 5 ▶use Math::PlanePath;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 5 @ISA = ('Math::PlanePath');
61  
62 use Math::PlanePath::Base::Generic
63 5 'is_infinite',
64 5 ▶ 'round_nearest';
Subroutine BEGIN: called CC=1 SCAR=0.0
65 use Math::PlanePath::Base::Digits
66 5 'round_down_pow',
67 'digit_split_lowtohigh',
68 5 ▶ 'digit_join_lowtohigh';
Subroutine BEGIN: called CC=1 SCAR=0.0
69 5 ▶use Math::PlanePath::Base::NSEW;
Subroutine BEGIN: called CC=1 SCAR=0.0
70  
71 # uncomment this to run the ### lines
72 # use Smart::Comments;
73  
74  
75 5 ▶use constant n_start => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 5 ▶use constant class_x_negative => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 5 ▶use constant class_y_negative => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 5 *xy_is_visited = \&Math::PlanePath::Base::Generic::xy_is_visited_quad1;
79  
80 5 use constant parameter_info_array =>
81 [ { name => 'radix',
82 display => 'Radix',
83 share_key => 'radix_3',
84 type => 'integer',
85 minimum => 2,
86 default => 3,
87 width => 3,
88 5 ▶ } ];
Subroutine BEGIN: called CC=1 SCAR=0.0
89  
90 # shared by WunderlichSerpentine
91 sub dx_minimum {
92 0 ▶ my ($self) = @_;
Subroutine dx_minimum: not called CC=2 SCAR=17.9
Pod documented
93 0 ▶ return ($self->{'radix'} % 2
Branch: 1 branch
BranchTrueFalseTotal
$self->{'radix'} % 2 ? : 0 0 0
94 ? -1 # odd
95 : undef); # even, unlimited
96 }
97 sub dx_maximum {
98 0 ▶ my ($self) = @_;
Subroutine dx_maximum: not called CC=2 SCAR=17.9
Pod documented
99 0 ▶ return ($self->{'radix'} % 2
Branch: 1 branch
BranchTrueFalseTotal
$self->{'radix'} % 2 ? : 0 0 0
100 ? 1 # odd
101 : undef); # even, unlimited
102 }
103  
104 # shared by WunderlichSerpentine
105 sub _UNDOCUMENTED__dxdy_list {
106 0 ▶ my ($self) = @_;
Subroutine _UNDOCUMENTED__dxdy_list: not called CC=2 SCAR=17.9
107 0 ▶ return ($self->{'radix'} % 2
Branch: 1 branch
BranchTrueFalseTotal
$self->{'radix'} % 2 ? : 0 0 0
108 ? Math::PlanePath::Base::NSEW->_UNDOCUMENTED__dxdy_list
109 : ()); # even, unlimited
110 }
111 # *--- b^2-1 -- b^2 ---- b^2+b-1 = (b+1)b-1
112 # | |
113 # *-------
114 # |
115 # 0 ----- b
116 #
117 sub _UNDOCUMENTED__dxdy_list_at_n {
118 0 ▶ my ($self) = @_;
Subroutine _UNDOCUMENTED__dxdy_list_at_n: not called CC=1 SCAR=6.9
119 0 return ($self->{'radix'} + 1) * $self->{'radix'} - 1;
120 }
121  
122 # shared by WunderlichSerpentine
123 5 *dy_minimum = \&dx_minimum;
124 5 *dy_maximum = \&dx_maximum;
125  
126 5 *dsumxy_minimum = \&dx_minimum;
127 5 *dsumxy_maximum = \&dx_maximum;
128  
129 5 *ddiffxy_minimum = \&dx_minimum;
130 5 *ddiffxy_maximum = \&dx_maximum;
131  
132 sub dir_maximum_dxdy {
133 0 ▶ my ($self) = @_;
Subroutine dir_maximum_dxdy: not called CC=2 SCAR=17.9
Pod documented
134 0 ▶ return ($self->{'radix'} % 2
Branch: 1 branch
BranchTrueFalseTotal
$self->{'radix'} % 2 ? : 0 0 0
135 ? (0,-1) # odd, South
136 : (0,0)); # even, supremum
137 }
138  
139 sub _UNDOCUMENTED__turn_any_left_at_n {
140 0 ▶ my ($self) = @_;
Subroutine _UNDOCUMENTED__turn_any_left_at_n: not called CC=1 SCAR=6.9
141 0 return $self->{'radix'} - 1;
142 }
143 sub _UNDOCUMENTED__turn_any_right_at_n {
144 0 ▶ my ($self) = @_;
Subroutine _UNDOCUMENTED__turn_any_right_at_n: not called CC=2 SCAR=17.9
145 return ($self->{'radix'} == 2 ? 5
146 0 ▶ : 2*$self->{'radix'} - 1);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'radix'} == 2 ? : 0 0 0
147 }
148  
149  
150 #------------------------------------------------------------------------------
151  
152 sub new {
153 11 ▶ my $self = shift->SUPER::new(@_);
Subroutine new: called CC=3 SCAR=11.0
Pod documented
154  
155 11 ▶ if (! $self->{'radix'} || $self->{'radix'} < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"radix"} or $self->{"radix"} < 2) 7 4 11
Condition66%2/3
not $self->{"radix"} or $self->{"radix"} < 2
l!l&&r!l&&!r
704
MC/DC50%1/2
not $self->{"radix"} or $self->{"radix"} < 2
not $self->{"radix"} $self->{"radix"} < 2
Truth table66%2/3
not(A) or B
A= not $self->{"radix"}B= $self->{"radix"} < 2
ABresult
1X1
011
000
156 7 $self->{'radix'} = 3;
157 }
158 11 return $self;
159 }
160  
161 sub _n_to_xykk {
162 60585 ▶ my ($self, $n) = @_;
Subroutine _n_to_xykk: called CC=5 SCAR=16.1
163 60585 my $radix = $self->{'radix'};
164 60585 my $radix_minus_1 = $radix - 1;
165  
166 60585 my @ndigits = digit_split_lowtohigh($n,$radix);
167 60585 ▶ if (scalar(@ndigits) & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @ndigits & 1) 52494 8091 60585
168 52494 push @ndigits, 0; # so even number of entries
169 }
170 ### @ndigits
171  
172 60585 my $xk = 0;
173 60585 my $yk = 0;
174 60585 my @ydigits;
175 my @xdigits;
176  
177 60585 ▶ for (my $i = $#ndigits >> 1; @ndigits; $i--) { # high to low
Branch: 1 branch
BranchTrueFalseTotal
if (@ndigits) 172473 60585 233058
178 ### $i
179 {
180 172473 my $ndigit = pop @ndigits; # high to low
181 172473 $xk ^= $ndigit;
182 172473 ▶ $ydigits[$i] = ($yk & 1 ? $radix_minus_1-$ndigit : $ndigit);
Branch: 1 branch
BranchTrueFalseTotal
$yk & 1 ? : 55512 116961 172473
183 }
184 {
185 172473 my $ndigit = pop @ndigits;
186 172473 $yk ^= $ndigit;
187 172473 ▶ $xdigits[$i] = ($xk & 1 ? $radix_minus_1-$ndigit : $ndigit);
Branch: 1 branch
BranchTrueFalseTotal
$xk & 1 ? : 55184 117289 172473
188 }
189 }
190 60585 my $zero = $n*0;
191 60585 return ((map {digit_join_lowtohigh($_, $radix, $zero)} \@xdigits, \@ydigits),
192 $xk,$yk);
193 }
194  
195  
196 sub n_to_xy {
197 20183 ▶ my ($self, $n) = @_;
Subroutine n_to_xy: called CC=4 SCAR=14.1
Pod documented
198 ### PeanoCurve n_to_xy(): $n
199 20183 ▶ if ($n < 0) { # negative
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 0) 0 20183 20183
200 0 return;
201 }
202 20183 ▶ if (is_infinite($n)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_infinite($n)) 0 20183 20183
203 0 return ($n,$n);
204 }
205  
206 {
207 # ENHANCE-ME: for odd radix the ends join and the direction can be had
208 # without a full N+1 calculation
209 20183 my $int = int($n);
210 ### $int
211 ### $n
212 20183 ▶ if ($n != $int) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n != $int) 1 20182 20183
213 1 my ($x1,$y1) = $self->n_to_xy($int);
214 1 my ($x2,$y2) = $self->n_to_xy($int+1);
215 1 my $frac = $n - $int; # inherit possible BigFloat
216 1 my $dx = $x2-$x1;
217 1 my $dy = $y2-$y1;
218 1 return ($frac*$dx + $x1, $frac*$dy + $y1);
219 }
220 20182 $n = $int; # BigFloat int() gives BigInt, use that
221 }
222  
223 20182 my ($x,$y) = _n_to_xykk($self,$n);
224 20182 return ($x,$y);
225 }
226  
227 sub _xykk_to_n {
228 853 ▶ my ($self, $x,$y, $offset_xk,$offset_yk) = @_;
Subroutine _xykk_to_n: called CC=14 SCAR=26.4
229 ### PeanoCurve _xykk_to_n(): "$x, $y offset $offset_xk,$offset_yk"
230  
231 853 ▶ if (($offset_xk && ($x-=$offset_xk) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($offset_xk and ($x -= $offset_xk) < 0 or $offset_yk and ($y -= $offset_yk) < 0) 11 842 853
Condition100%9/9
$offset_xk and ($x -= $offset_xk) < 0 or $offset_yk and ($y -= $offset_yk) < 0
l!l&&r!l&&!r
612835
$offset_xk and ($x -= $offset_xk) < 0
!ll&&!rl&&r
792556
$offset_yk and ($y -= $offset_yk) < 0
!ll&&!rl&&r
790525
MC/DC75%3/4
$offset_xk and ($x -= $offset_xk) < 0 or $offset_yk and ($y -= $offset_yk) < 0
$offset_xk ($x -= $offset_xk) < 0 $offset_yk ($y -= $offset_yk) < 0
Truth table71%5/7
A and B or C and D
A= $offset_xkB= ($x -= $offset_xk) < 0C= $offset_ykD= ($y -= $offset_yk) < 0
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
232 || ($offset_yk && ($y-=$offset_yk) < 0)) {
233 11 return; # offset goes negative
234 }
235  
236 842 my $radix = $self->{'radix'};
237 842 my @x = digit_split_lowtohigh ($x, $radix);
238 842 my @y = digit_split_lowtohigh ($y, $radix);
239  
240 842 my $radix_minus_1 = $radix - 1;
241 842 my $xk = 0;
242 842 my $yk = 0;
243  
244 842 my @n; # stored low to high, generated from high to low
245 842 my $i_high = max($#x,$#y);
246 842 my $npos = 2*$i_high+1;
247  
248 842 foreach my $i (reverse 0 .. $i_high) { # high to low
249 {
250 4159 ▶ my $digit = $y[$i] || 0;
Condition100%2/2
$y[$i] || 0
l!l
30111148
MC/DC100%1/1
$y[$i] || 0
$y[$i]
Truth table100%2/2
A
A= $y[$i]
Aresult
11
00
251 4159 ▶ if ($yk & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yk & 1) 1670 2489 4159
252 1670 $digit = $radix_minus_1 - $digit; # reverse digit
253 }
254 4159 $n[$npos--] = $digit;
255 4159 $xk ^= $digit;
256 }
257 {
258 4159 ▶ my $digit = $x[$i] || 0;
Condition100%2/2
$x[$i] || 0
l!l
30091150
MC/DC100%1/1
$x[$i] || 0
$x[$i]
Truth table100%2/2
A
A= $x[$i]
Aresult
11
00
259 4159 ▶ if ($xk & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xk & 1) 2084 2075 4159
260 2084 $digit = $radix_minus_1 - $digit; # reverse digit
261 }
262 4159 $n[$npos--] = $digit;
263 4159 $yk ^= $digit;
264 }
265 }
266 ### final n: @n
267 ### final xkyk: ($xk&1).' '.($yk&1)
268 842 ▶ return ((! defined $offset_xk || ($xk&1) == $offset_xk)
Branch: 1 branch
BranchTrueFalseTotal
(!defined($offset_xk) || ($xk & 1) == $offset_xk) && (!defined($offset_yk) || ($yk & 1) == $offset_yk) ? : 787 55 842
Condition100%9/9
!defined($offset_xk) || ($xk & 1) == $offset_xk and !defined($offset_yk) || ($yk & 1) == $offset_yk
!ll&&!rl&&r
4114787
not defined $offset_xk or ($xk & 1) == $offset_xk
l!l&&r!l&&!r
7317041
not defined $offset_yk or ($yk & 1) == $offset_yk
l!l&&r!l&&!r
7315614
MC/DC75%3/4
!defined($offset_xk) || ($xk & 1) == $offset_xk and !defined($offset_yk) || ($yk & 1) == $offset_yk
not defined $offset_xk ($xk & 1) == $offset_xk not defined $offset_yk ($yk & 1) == $offset_yk
Truth table57%4/7
not(A) or B and not(C) or D
A= not defined $offset_xkB= ($xk & 1) == $offset_xkC= not defined $offset_ykD= ($yk & 1) == $offset_yk
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
269 && (! defined $offset_yk || ($yk&1) == $offset_yk)
270 ? (digit_join_lowtohigh (\@n, $radix,
271 $x*0*$y)) # inherit bignum 0
272 : ());
273 }
274  
275 sub xy_to_n {
276 731 ▶ my ($self, $x, $y) = @_;
Subroutine xy_to_n: called CC=5 SCAR=19.3
Pod documented
277 ### PeanoCurve xy_to_n(): "$x, $y"
278  
279 731 $x = round_nearest ($x);
280 731 $y = round_nearest ($y);
281  
282 731 ▶ if ($x < 0 || $y < 0) { return undef; }
Branch: 1 branch
BranchTrueFalseTotal
if ($x < 0 or $y < 0) 0 731 731
Condition33%1/3
$x < 0 or $y < 0
l!l&&r!l&&!r
00731
MC/DC0%0/2
$x < 0 or $y < 0
$x < 0 $y < 0
Truth table33%1/3
A or B
A= $x < 0B= $y < 0
ABresult
1X1
011
000
283 731 ▶ if (is_infinite($x)) { return $x; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_infinite($x)) 0 731 731
284 731 ▶ if (is_infinite($y)) { return $y; }
Branch: 1 branch
BranchTrueFalseTotal
if (is_infinite($y)) 0 731 731
285  
286 731 return _xykk_to_n($self, $x,$y);
287 }
288  
289 # exact
290 sub rect_to_n_range {
291 1 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine rect_to_n_range: called CC=19 SCAR=30.9
Pod documented
292  
293 1 $x1 = round_nearest ($x1);
294 1 $y1 = round_nearest ($y1);
295 1 $x2 = round_nearest ($x2);
296 1 $y2 = round_nearest ($y2);
297 1 ▶ ($x1,$x2) = ($x2,$x1) if $x1 > $x2;
Branch: 1 branch
BranchTrueFalseTotal
if $x1 > $x2 0 1 1
298 1 ▶ ($y1,$y2) = ($y2,$y1) if $y1 > $y2;
Branch: 1 branch
BranchTrueFalseTotal
if $y1 > $y2 0 1 1
299 ### rect_to_n_range(): "$x1,$y1 to $x2,$y2"
300  
301 1 ▶ if ($x2 < 0 || $y2 < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x2 < 0 or $y2 < 0) 0 1 1
Condition33%1/3
$x2 < 0 or $y2 < 0
l!l&&r!l&&!r
001
MC/DC0%0/2
$x2 < 0 or $y2 < 0
$x2 < 0 $y2 < 0
Truth table33%1/3
A or B
A= $x2 < 0B= $y2 < 0
ABresult
1X1
011
000
302 0 return (1, 0);
303 }
304  
305 1 my $radix = $self->{'radix'};
306  
307 1 my ($power, $level) = round_down_pow (max($x2,$y2), $radix);
308 1 ▶ if (is_infinite($level)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_infinite($level)) 0 1 1
309 0 return (0, $level);
310 }
311  
312 1 my $n_power = $power * $power * $radix;
313 1 my $max_x = 0;
314 1 my $max_y = 0;
315 1 my $max_n = 0;
316 1 my $max_xk = 0;
317 1 my $max_yk = 0;
318  
319 1 my $min_x = 0;
320 1 my $min_y = 0;
321 1 my $min_n = 0;
322 1 my $min_xk = 0;
323 1 my $min_yk = 0;
324  
325 # l<=c<h doesn't overlap c1<=c<=c2 if
326 # l>c2 or h-1<c1
327 # l>c2 or h<=c1
328 # so does overlap if
329 # l<=c2 and h>c1
330 #
331 1 my $radix_minus_1 = $radix - 1;
332 my $overlap = sub {
333 5 ▶ my ($c,$ck,$digit, $c1,$c2) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
334 5 ▶ if ($ck & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ck & 1) 1 4 5
335 1 $digit = $radix_minus_1 - $digit;
336 }
337 ### overlap consider: "inv".($ck&1)."digit=$digit ".($c+$digit*$power)."<=c<".($c+($digit+1)*$power)." cf $c1 to $c2 incl"
338 5 ▶ return ($c + $digit*$power <= $c2
Condition66%2/3
$c + $digit * $power <= $c2 && $c + ($digit + 1) * $power > $c1
!ll&&!rl&&r
104
MC/DC50%1/2
$c + $digit * $power <= $c2 && $c + ($digit + 1) * $power > $c1
$c + $digit * $power <= $c2 $c + ($digit + 1) * $power > $c1
Truth table66%2/3
A && B
A= $c + $digit * $power <= $c2B= $c + ($digit + 1) * $power > $c1
ABresult
0X0
100
111
339 && $c + ($digit+1)*$power > $c1);
340 1 };
341  
342 1 ▶ while ($level-- >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level-- >= 0) 1 1 2
343 ### $power
344 ### $n_power
345 ### $max_n
346 ### $min_n
347 {
348 1 my $digit;
349 1 ▶ for ($digit = $radix_minus_1; $digit > 0; $digit--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit > 0) 2 0 2
350 2 ▶ last if &$overlap ($max_y,$max_yk,$digit, $y1,$y2);
Branch: 1 branch
BranchTrueFalseTotal
if &$overlap($max_y, $max_yk, $digit, $y1, $y2) 1 1 2
351 }
352 1 $max_n += $n_power * $digit;
353 1 $max_xk ^= $digit;
354 1 ▶ if ($max_yk&1) { $digit = $radix_minus_1 - $digit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($max_yk & 1) 0 1 1
355 1 $max_y += $power * $digit;
356 ### max y digit (complemented): $digit
357 ### $max_y
358 ### $max_n
359 }
360 {
361 1 my $digit;
362 1 ▶ for ($digit = 0; $digit < $radix_minus_1; $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit < $radix_minus_1) 1 0 1
363 1 ▶ last if &$overlap ($min_y,$min_yk,$digit, $y1,$y2);
Branch: 1 branch
BranchTrueFalseTotal
if &$overlap($min_y, $min_yk, $digit, $y1, $y2) 1 0 1
364 }
365 1 $min_n += $n_power * $digit;
366 1 $min_xk ^= $digit;
367 1 ▶ if ($min_yk&1) { $digit = $radix_minus_1 - $digit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($min_yk & 1) 0 1 1
368 1 $min_y += $power * $digit;
369 ### min y digit (complemented): $digit
370 ### $min_y
371 ### $min_n
372 }
373  
374 1 $n_power = int($n_power/$radix);
375 {
376 1 my $digit;
377 1 ▶ for ($digit = $radix_minus_1; $digit > 0; $digit--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit > 0) 1 0 1
378 1 ▶ last if &$overlap ($max_x,$max_xk,$digit, $x1,$x2);
Branch: 1 branch
BranchTrueFalseTotal
if &$overlap($max_x, $max_xk, $digit, $x1, $x2) 1 0 1
379 }
380 1 $max_n += $n_power * $digit;
381 1 $max_yk ^= $digit;
382 1 ▶ if ($max_xk&1) { $digit = $radix_minus_1 - $digit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($max_xk & 1) 1 0 1
383 1 $max_x += $power * $digit;
384 ### max x digit (complemented): $digit
385 ### $max_x
386 ### $max_n
387 }
388 {
389 1 my $digit;
390 1 ▶ for ($digit = 0; $digit < $radix_minus_1; $digit++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digit < $radix_minus_1) 1 0 1
391 1 ▶ last if &$overlap ($min_x,$min_xk,$digit, $x1,$x2);
Branch: 1 branch
BranchTrueFalseTotal
if &$overlap($min_x, $min_xk, $digit, $x1, $x2) 1 0 1
392 }
393 1 $min_n += $n_power * $digit;
394 1 $min_yk ^= $digit;
395 1 ▶ if ($min_xk&1) { $digit = $radix_minus_1 - $digit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($min_xk & 1) 0 1 1
396 1 $min_x += $power * $digit;
397 ### min x digit (complemented): $digit
398 ### $min_x
399 ### $min_n
400 }
401  
402 1 $power = int($power/$radix);
403 1 $n_power = int($n_power/$radix);
404 }
405 ### is: "$min_n at $min_x,$min_y to $max_n at $max_x,$max_y"
406 1 return ($min_n, $max_n);
407 }
408  
409 #------------------------------------------------------------------------------
410 # levels
411  
412 5 ▶use Math::PlanePath::ZOrderCurve;
Subroutine BEGIN: called CC=1 SCAR=0.0
413 5 *level_to_n_range = \&Math::PlanePath::ZOrderCurve::level_to_n_range;
414 5 *n_to_level = \&Math::PlanePath::ZOrderCurve::n_to_level;
415  
416 #------------------------------------------------------------------------------
417 5 1;
418 __END__
« PlanePath/QuintetReplicate.pm ↑ Summary PlanePath/QuintetCurve.pm »