NumSeq/PlanePathTurn.pm untested

filter: Statementstmt 0.0% 0 / 720 Branchbran 0.0% 0 / 128 Conditioncond 0.0% 0 / 75 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 184 Podpod 0.0% 0 / 73 totaltotal 0.0% 0 / 1180 SCAR 83.6
CC
65
Cov
0%
pred
156.0
characteristic_non_decreasing
30.0
next
12.0
CRAP 4290.0
1 # Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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 # math-image --values=PlanePathTurn
20 #
21 # maybe:
22 # Turn4 0,1,2,3 and fractional
23 # Turn4n 0,1,2,-1 negatives Turn4mid Turn4n Turn4s
24 # TTurn6n 0,1,2,3, -1,-2, eg. flowsnake TTurn6s
25 # TTurn6 0,1,2,3,4,5
26  
27  
28  
29 package Math::NumSeq::PlanePathTurn;
30 use 5.004;
31 use strict;
32 use Carp 'croak';
33  
34 use vars '$VERSION','@ISA';
35 $VERSION = 127;
36 use Math::NumSeq;
37 @ISA = ('Math::NumSeq');
38  
39 use Math::NumSeq::PlanePathCoord;
40 use Math::PlanePath;
41 use Math::PlanePath::Base::Generic
42 'is_infinite';
43 use Math::NumSeq::PlanePathDelta;
44  
45 # uncomment this to run the ### lines
46 # use Smart::Comments;
47  
48 use constant characteristic_smaller => 1;
49  
50 sub description {
51 my ($self) = @_;
52 if (ref $self) {
53 return "Turn values $self->{'turn_type'} from path $self->{'planepath'}";
54 } else {
55 # class method
56 return 'Turns from a PlanePath';
57 }
58 }
59  
60 use constant::defer parameter_info_array =>
61 sub {
62 return [
63 Math::NumSeq::PlanePathCoord::_parameter_info_planepath(),
64 {
65 name => 'turn_type',
66 display => 'Turn Type',
67 type => 'enum',
68 default => 'Left',
69 choices => ['Left','Right','Straight','NotStraight',
70 'LSR','SLR','SRL',
71
72 # 'RSL',
73 # 'Turn4', # Turn4 is 0<=value<4.
74 # 'Turn4n',
75 # 'TTurn6',
76 ],
77 description => 'Left is 1=left, 0=right or straight.
78 Right is 1=right, 0=left or straight.
79 LSR is 1=left,0=straight,-1=right.
80 SLR is 0=straight,1=left,2=right.
81 SRL is 0=straight,1=right,2=left.',
82 },
83 ];
84 };
85  
86 sub characteristic_integer {
87 my ($self) = @_;
88 my $planepath_object = $self->{'planepath_object'};
89 if (my $func = $planepath_object->can("_NumSeq_Turn_$self->{'turn_type'}_integer")) {
90 return $planepath_object->$func();
91 }
92 return undef;
93 }
94  
95 #------------------------------------------------------------------------------
96  
97 sub oeis_anum {
98 my ($self) = @_;
99 ### PlanePathTurn oeis_anum() ...
100  
101 my $planepath = $self->{'planepath_object'};
102 my $key = Math::NumSeq::PlanePathCoord::_planepath_oeis_anum_key($self->{'planepath_object'});
103  
104 ### planepath: ref $planepath
105 ### $key
106 ### whole table: $planepath->_NumSeq_Turn_oeis_anum
107 ### key href: $planepath->_NumSeq_Turn_oeis_anum->{$key}
108  
109 return $planepath->_NumSeq_Turn_oeis_anum->{$key}->{$self->{'turn_type'}};
110 }
111  
112 #------------------------------------------------------------------------------
113  
114 sub new {
115 ### PlanePathTurn new(): @_
116 my $self = shift->SUPER::new(@_);
117 ### self from SUPER: $self
118  
119 $self->{'planepath_object'}
120 ||= Math::NumSeq::PlanePathCoord::_planepath_name_to_object($self->{'planepath'});
121  
122 ### turn_func: "_turn_func_$self->{'turn_type'}", $self->{'turn_func'}
123 $self->{'turn_func'} = $self->can('_turn_func_'.$self->{'turn_type'})
124 || croak "Unrecognised turn_type: ",$self->{'turn_type'};
125  
126 $self->rewind;
127 ### $self
128 return $self;
129 }
130  
131 sub i_start {
132 my ($self) = @_;
133 my $planepath_object = $self->{'planepath_object'} || return 0;
134 return $planepath_object->n_start + $planepath_object->arms_count;
135 }
136 sub rewind {
137 my ($self) = @_;
138 my $planepath_object = $self->{'planepath_object'} || return;
139  
140 $self->{'i'} = $self->i_start;
141 $self->{'arms'} = $planepath_object->arms_count;
142 undef $self->{'prev_dx'};
143 }
144  
145 sub next {
146 my ($self) = @_;
147 ### NumSeq-PlanePathTurn next(): "i=$self->{'i'}"
148  
149 my $planepath_object = $self->{'planepath_object'};
150  
151 my $i = $self->{'i'}++;
152 my $arms = $self->{'arms'};
153  
154 my $prev_dx = $self->{'prev_dx'};
155 my $prev_dy;
156 if (defined $prev_dx) {
157 $prev_dy = $self->{'prev_dy'};
158 ### use prev dxdy: "$prev_dx,$prev_dy"
159 } else {
160 ($prev_dx, $prev_dy) = $planepath_object->n_to_dxdy($i-$arms)
161 or do {
162 ### nothing in path at n: $i
163 return;
164 };
165 ### calc prev dxdy: "at i=".($i-$arms)." $prev_dx,$prev_dy"
166 }
167  
168 my ($dx, $dy) = $planepath_object->n_to_dxdy($i)
169 or do {
170 ### nothing in path at previous n: $i-$arms
171 return;
172 };
173 ### calc dxdy: "at i=$i $dx,$dy"
174  
175 if ($arms == 1) {
176 $self->{'prev_dx'} = $dx;
177 $self->{'prev_dy'} = $dy;
178 }
179 return ($i, $self->{'turn_func'}->($prev_dx,$prev_dy, $dx,$dy));
180 }
181  
182 sub ith {
183 my ($self, $i) = @_;
184 ### PlanePathTurn ith(): $i
185  
186 if (is_infinite($i)) {
187 return undef;
188 }
189 my $planepath_object = $self->{'planepath_object'};
190 my $arms = $self->{'arms'};
191 my ($prev_dx, $prev_dy) = $planepath_object->n_to_dxdy($i - $arms)
192 or return undef;
193 my ($dx, $dy) = $planepath_object->n_to_dxdy($i)
194 or return undef;
195 return $self->{'turn_func'}->($prev_dx,$prev_dy, $dx,$dy);
196 }
197  
198 # dx1,dy1
199 # dx2,dy2 /
200 # * /
201 # /
202 # /
203 # /
204 # /
205 # O
206 #
207 # cmpy = dx2 * dy1/dx1
208 # left if dy2 > cmpy
209 # dy2 > dx2 * dy1/dx1
210 # dy2 * dx1 > dx2 * dy1
211 #
212 # if dx1=0, dy1 > 0 then left if dx2 < 0
213 # dy2 * 0 > dx2 * dy1
214 # 0 > dx2*dy1 good
215 #
216 sub _turn_func_Left {
217 my ($dx,$dy, $next_dx,$next_dy) = @_;
218 ### _turn_func_Left() ...
219 return ($next_dy * $dx > $next_dx * $dy ? 1 : 0);
220 }
221 sub _turn_func_Right {
222 my ($dx,$dy, $next_dx,$next_dy) = @_;
223 ### _turn_func_Right() ...
224 return ($next_dy * $dx < $next_dx * $dy ? 1 : 0);
225 }
226 sub _turn_func_LSR {
227 my ($dx,$dy, $next_dx,$next_dy) = @_;
228 ### _turn_func_LSR() ...
229 return (($next_dy * $dx <=> $next_dx * $dy) || 0); # 1,0,-1
230 }
231 sub _turn_func_RSL {
232 return - _turn_func_LSR(@_);
233 }
234 {
235 my @LSR_to_SLR = (0, # LSR=0 straight -> SLR=0
236 1, # LSR=1 left -> SLR=1
237 2); # LSR=-1 right -> SLR=2
238 sub _turn_func_SLR {
239 return $LSR_to_SLR[_turn_func_LSR(@_)];
240 }
241 }
242 {
243 my @LSR_to_SRL = (0, # LSR=0 straight -> SRL=0
244 2, # LSR=1 left -> SRL=2
245 1); # LSR=-1 right -> SRL=1
246 sub _turn_func_SRL {
247 return $LSR_to_SRL[_turn_func_LSR(@_)];
248 }
249 }
250 sub _turn_func_Straight {
251 my ($dx,$dy, $next_dx,$next_dy) = @_;
252 ### _turn_func_Left() ...
253 return ($next_dy * $dx == $next_dx * $dy ? 1 : 0);
254 }
255 sub _turn_func_NotStraight {
256 my ($dx,$dy, $next_dx,$next_dy) = @_;
257 ### _turn_func_Left() ...
258 return ($next_dy * $dx == $next_dx * $dy ? 0 : 1);
259 }
260  
261 #---------------
262 # experimental extras
263  
264 # sub _turn_func_LR_01 {
265 # my ($dx,$dy, $next_dx,$next_dy) = @_;
266 # ### _turn_func_LR_01() ...
267 # return ($next_dy * $dx >= $next_dx * $dy || 0);
268 # }
269  
270 # 0,1,2,3 as ddir mod 4, incl fractional
271 sub _turn_func_Turn4 {
272 my ($dx,$dy, $next_dx,$next_dy) = @_;
273 ### _turn_func_Turn4(): "$dx,$dy $next_dx,$next_dy"
274 return
275 (((Math::NumSeq::PlanePathDelta::_delta_func_Dir360($next_dx,$next_dy)
276 - Math::NumSeq::PlanePathDelta::_delta_func_Dir360($dx,$dy)) % 360)
277 / 90);
278 }
279 # 0,1,2, -1
280 # MAYBE: 0 <= t < 2 and -2 <= t < 0 for symmetry, so reverse=-2
281 sub _turn_func_Turn4n {
282 my ($dx,$dy, $next_dx,$next_dy) = @_;
283 require Math::NumSeq::PlanePathDelta;
284 my $ret
285 = (((Math::NumSeq::PlanePathDelta::_delta_func_Dir360($next_dx,$next_dy)
286 - Math::NumSeq::PlanePathDelta::_delta_func_Dir360($dx,$dy)) % 360)
287 / 90);
288 if ($ret > 2) { $ret -= 4; }
289 return $ret;
290 }
291  
292 # 0,1,2,3,4,5 as dtdir mod 6, incl fractional
293 sub _turn_func_TTurn6 {
294 my ($dx,$dy, $next_dx,$next_dy) = @_;
295 require Math::NumSeq::PlanePathDelta;
296 return
297 (((Math::NumSeq::PlanePathDelta::_delta_func_TDir360($next_dx,$next_dy)
298 - Math::NumSeq::PlanePathDelta::_delta_func_TDir360($dx,$dy)) % 360)
299 / 60);
300 }
301 # 0,1,2,3, -2,-1
302 # MAYBE: 0 <= t < 3 and -3 <= t < 0 for symmetry, so reverse=-3
303 sub _turn_func_TTurn6n {
304 my $t = _turn_func_TTurn6(@_);
305 return ($t <= 3 ? $t : $t-6);
306 }
307  
308 #---------
309  
310 sub pred {
311 my ($self, $value) = @_;
312 ### PlanePathTurn pred(): $value
313 my $planepath_object = $self->{'planepath_object'};
314  
315 if (defined (my $values_min = $self->values_min)) {
316 if ($value < $values_min) {
317 return 0;
318 }
319 }
320 if (defined (my $values_max = $self->values_max)) {
321 if ($value > $values_max) {
322 return 0;
323 }
324 }
325  
326 my $turn_type = $self->{'turn_type'};
327 if ($turn_type eq 'Left' || $turn_type eq 'Right'
328 || $turn_type eq 'Straight' || $turn_type eq 'NotStraight') {
329 unless ($value == 0 || $value == 1) {
330 return 0;
331 }
332 } elsif ($turn_type eq 'LSR' || $turn_type eq 'RSL') {
333 unless ($value == 1 || $value == 0 || $value == -1) {
334 return 0;
335 }
336 } else { # ($turn_type eq 'SLR' || $turn_type eq 'SRL') {
337 unless ($value == 0 || $value == 1 || $value == 2) {
338 return 0;
339 }
340 }
341  
342 if (my $func = $planepath_object->can('_NumSeq_Turn_'.$self->{'turn_type'}.'_pred_hash')) {
343 my $href = $self->$func();
344 unless ($href->{$value}) {
345 return 0;
346 }
347 }
348  
349 return 1;
350 }
351  
352  
353  
354 #------------------------------------------------------------------------------
355  
356 sub values_min {
357 my ($self) = @_;
358  
359 my $method = '_NumSeq_Turn_' . $self->{'turn_type'} . '_min';
360 return $self->{'planepath_object'}->can($method)
361 ? $self->{'planepath_object'}->$method()
362 : undef;
363 }
364  
365 sub values_max {
366 my ($self) = @_;
367  
368 my $method = '_NumSeq_Turn_' . $self->{'turn_type'} . '_max';
369 return $self->{'planepath_object'}->can($method)
370 ? $self->{'planepath_object'}->$method()
371 : undef;
372 }
373  
374 sub characteristic_increasing {
375 my ($self) = @_;
376 my $planepath_object = $self->{'planepath_object'};
377 if (my $func = $planepath_object->can("_NumSeq_Turn_$self->{'turn_type'}_increasing")) {
378 return $planepath_object->$func();
379 }
380 return undef; # unknown
381 }
382  
383 sub characteristic_non_decreasing {
384 my ($self) = @_;
385 my $planepath_object = $self->{'planepath_object'};
386 if (my $func = $planepath_object->can("_NumSeq_Turn_$self->{'turn_type'}_non_decreasing")) {
387 return $planepath_object->$func();
388 }
389 if (defined (my $values_min = $self->values_min)) {
390 if (defined (my $values_max = $self->values_max)) {
391 if ($values_min == $values_max) {
392 # constant seq is non-decreasing
393 return 1;
394 }
395 }
396 }
397 # increasing means non_decreasing too
398 return $self->characteristic_increasing;
399 }
400  
401 # my $all_Left_predhash = { 0=>1, 1=>1 };
402 # my $all_LSR_predhash = { 0=>1, 1=>1, -1=>1 };
403 # my $straight_Left_predhash = { 0=>1 };
404 # my $straight_LSR_predhash = { 0=>1 };
405  
406 { package Math::PlanePath;
407 use constant 1.02; # for leading underscore
408  
409 sub _NumSeq_Turn_Left_min {
410 my ($self) = @_;
411 return ($self->turn_any_right
412 || $self->turn_any_straight ? 0 : 1);
413 }
414 sub _NumSeq_Turn_Left_max {
415 my ($self) = @_;
416 return ($self->turn_any_left ? 1 : 0);
417 }
418 use constant _NumSeq_Turn_Left_integer => 1;
419  
420 sub _NumSeq_Turn_Right_min {
421 my ($self) = @_;
422 return ($self->turn_any_left
423 || $self->turn_any_straight ? 0 : 1);
424 }
425 sub _NumSeq_Turn_Right_max {
426 my ($self) = @_;
427 return ($self->turn_any_right ? 1 : 0);
428 }
429 use constant _NumSeq_Turn_Right_integer => 1;
430  
431 sub _NumSeq_Turn_Straight_min {
432 my ($self) = @_;
433 return ($self->turn_any_left
434 || $self->turn_any_right ? 0 : 1);
435 }
436 sub _NumSeq_Turn_Straight_max {
437 my ($self) = @_;
438 return ($self->turn_any_straight ? 1 : 0);
439 }
440 use constant _NumSeq_Turn_Straight_integer => 1;
441  
442 sub _NumSeq_Turn_NotStraight_min {
443 my ($self) = @_;
444 return 1 - $self->_NumSeq_Turn_Straight_max; # NotStraight opposite
445 }
446 sub _NumSeq_Turn_NotStraight_max {
447 my ($self) = @_;
448 return 1 - $self->_NumSeq_Turn_Straight_min; # NotStraight opposite
449 }
450 use constant _NumSeq_Turn_NotStraight_integer => 1;
451  
452 sub _NumSeq_Turn_LSR_min {
453 my ($self) = @_;
454 return ($self->turn_any_right ? -1
455 : $self->turn_any_straight ? 0
456 : 1); # only ever Left
457 }
458 sub _NumSeq_Turn_LSR_max {
459 my ($self) = @_;
460 return ($self->turn_any_left ? 1
461 : $self->turn_any_straight ? 0
462 : -1); # only ever Right
463 }
464 use constant _NumSeq_Turn_LSR_integer => 1;
465  
466 sub _NumSeq_Turn_SLR_min {
467 my ($self) = @_;
468 return ($self->turn_any_straight ? 0
469 : $self->turn_any_left ? 1
470 : 2); # only ever Right
471 }
472 sub _NumSeq_Turn_SLR_max {
473 my ($self) = @_;
474 return ($self->turn_any_right ? 2
475 : $self->_NumSeq_Turn_Left_max); # 1 if any Left
476 }
477 use constant _NumSeq_Turn_SLR_integer => 1;
478  
479 sub _NumSeq_Turn_SRL_min {
480 my ($self) = @_;
481 return ($self->turn_any_straight ? 0
482 : $self->turn_any_right ? 1
483 : 2); # only ever Left
484 }
485 sub _NumSeq_Turn_SRL_max {
486 my ($self) = @_;
487 return ($self->turn_any_left ? 2
488 : $self->_NumSeq_Turn_Right_max); # 1 if any Right
489 }
490 use constant _NumSeq_Turn_SRL_integer => 1;
491  
492 use constant _NumSeq_Turn_Turn4_min => 0;
493 sub _NumSeq_Turn_Turn4_integer {
494 my ($self) = @_;
495 return $self->_NumSeq_Delta_Dir4_integer;
496 }
497 sub _NumSeq_Turn_Turn4_max {
498 my ($self) = @_;
499 return ($self->_NumSeq_Turn_Turn4_integer ? 3 : 4);
500 }
501  
502 use constant _NumSeq_Turn_oeis_anum => {};
503 }
504  
505 # { package Math::PlanePath::SquareSpiral;
506 # # SquareSpiral
507 # # abs(A167752)==Left=LSR=Turn4 if that really is the quarter-squares
508 # # abs(A167753)==Left=LSR=Turn4 of wider=1 if that really is the ceil(n+1)^2
509 # }
510 { package Math::PlanePath::GreekKeySpiral;
511 sub _NumSeq_Turn_Turn4_max {
512 my ($self) = @_;
513 return ($self->{'turns'} == 0
514 ? 1 # SquareSpiral, left or straight only
515 : 3); # otherwise turn right too
516 }
517 }
518 { package Math::PlanePath::PyramidSpiral;
519 use constant _NumSeq_Turn_Turn4_max => 1.5;
520 }
521 { package Math::PlanePath::TriangleSpiral;
522 use constant _NumSeq_Turn_Turn4_max => 1.5;
523  
524 use constant _NumSeq_Turn_oeis_anum =>
525 { 'n_start=-1' =>
526 { Left => 'A023531', # 1 at k*(k+3)/2
527 LSR => 'A023531',
528 Straight => 'A023532', # 0 at k*(k+3)/2, 1 otherwise
529 # OEIS-Other: A023531 planepath=TriangleSpiral,n_start=-1
530 # OEIS-Other: A023531 planepath=TriangleSpiral,n_start=-1 turn_type=LSR
531 # OEIS-Other: A023532 planepath=TriangleSpiral,n_start=-1 turn_type=Straight
532 },
533  
534 # PlanePathTurn planepath=TriangleSpiral,n_start=1, turn_type=TTurn6
535 # A089799 Expansion of Jacobi theta function theta_2(q^(1/2))/q^(1/8)
536 # is this 2s with runs of 0s ?
537 };
538 }
539 { package Math::PlanePath::TriangleSpiralSkewed;
540 use constant _NumSeq_Turn_Turn4_max => 1.5;
541  
542 use constant _NumSeq_Turn_oeis_anum =>
543 {
544 do {
545 my $href = { Left => 'A023531', # 1 at k*(k+3)/2
546 LSR => 'A023531',
547 Straight => 'A023532', # 0 at k*(k+3)/2, 1 otherwise
548 };
549 ('skew=left,n_start=-1' => $href,
550 'skew=right,n_start=-1' => $href,
551 'skew=up,n_start=-1' => $href,
552 'skew=down,n_start=-1' => $href)
553 # OEIS-Other: A023531 planepath=TriangleSpiralSkewed,n_start=-1
554 # OEIS-Other: A023531 planepath=TriangleSpiralSkewed,n_start=-1 turn_type=LSR
555 # OEIS-Other: A023532 planepath=TriangleSpiralSkewed,n_start=-1 turn_type=Straight
556 # OEIS-Other: A023531 planepath=TriangleSpiralSkewed,n_start=-1,skew=right
557 # OEIS-Other: A023531 planepath=TriangleSpiralSkewed,n_start=-1,skew=up
558 # OEIS-Other: A023531 planepath=TriangleSpiralSkewed,n_start=-1,skew=down
559 },
560 };
561 }
562 { package Math::PlanePath::DiamondSpiral;
563 use constant _NumSeq_Turn_Turn4_max => 1.5;
564 }
565 { package Math::PlanePath::AztecDiamondRings;
566 use constant _NumSeq_Turn_Turn4_max => 1; # left or straight
567 }
568 { package Math::PlanePath::PentSpiral;
569 use constant _NumSeq_Turn_Turn4_max =>
570 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(2,0, -2,1);
571 }
572 { package Math::PlanePath::PentSpiralSkewed;
573 use constant _NumSeq_Turn_Turn4_max => 1.5;
574 }
575 { package Math::PlanePath::HexSpiral;
576 use constant _NumSeq_Turn_Turn4_max => 1.5;
577 }
578 { package Math::PlanePath::HexSpiralSkewed;
579 use constant _NumSeq_Turn_Turn4_max => 1.5;
580 }
581 { package Math::PlanePath::HeptSpiralSkewed;
582 use constant _NumSeq_Turn_Turn4_max => 1.5; # at N=2 turn +135
583 }
584 { package Math::PlanePath::AnvilSpiral;
585 use constant _NumSeq_Turn_Turn4_max => 3;
586 }
587 { package Math::PlanePath::OctagramSpiral;
588 use constant _NumSeq_Turn_Turn4_max => 3; # +90 right
589 }
590 { package Math::PlanePath::KnightSpiral;
591 # use constant _NumSeq_Turn_Turn4_min => ...; # 2,1
592 }
593 # { package Math::PlanePath::CretanLabyrinth;
594 # }
595 { package Math::PlanePath::SquareArms;
596 use constant _NumSeq_Turn_Turn4_max => 1; # left or straight
597 }
598 { package Math::PlanePath::DiamondArms;
599 use constant _NumSeq_Turn_Turn4_max => 1; # left or straight
600 use constant _NumSeq_Turn_Turn4_integer => 1;
601 }
602 { package Math::PlanePath::HexArms;
603 use constant _NumSeq_Turn_Turn4_max => 1; # at N=8
604 }
605 { package Math::PlanePath::SacksSpiral;
606  
607 sub _NumSeq_Turn_Turn4_max {
608 my ($self) = @_;
609 # at N=1 is maximum turn
610 return Math::NumSeq::PlanePathTurn::_turn_func_Turn4(1,0,
611 $self->n_to_dxdy(1));
612 }
613 use constant _NumSeq_Turn4_min_is_infimum => 1;
614  
615 use constant _NumSeq_Turn_oeis_anum =>
616 { '' =>
617 { 'Left' => 'A000012', # left always, all ones
618 'LSR' => 'A000012',
619 # OEIS-Other: A000012 planepath=SacksSpiral
620 # OEIS-Other: A000012 planepath=SacksSpiral turn_type=LSR
621 },
622 };
623 }
624 # { package Math::PlanePath::VogelFloret;
625 # }
626 { package Math::PlanePath::TheodorusSpiral;
627 use constant _NumSeq_Turn4_min_is_infimum => 1; # approaches straight
628 use constant _NumSeq_Turn_Turn4_max => 1; # initial 90deg
629  
630 use constant _NumSeq_Turn_oeis_anum =>
631 { '' =>
632 { 'Left' => 'A000012', # left always, all ones
633 'LSR' => 'A000012',
634 # OEIS-Other: A000012 planepath=TheodorusSpiral
635 # OEIS-Other: A000012 planepath=TheodorusSpiral turn_type=LSR
636 },
637 };
638 }
639 { package Math::PlanePath::ArchimedeanChords;
640 sub _NumSeq_Turn_Turn4_max {
641 my ($self) = @_;
642 # at N=1 is maximum turn
643 return Math::NumSeq::PlanePathTurn::_turn_func_Turn4(1,0,
644 $self->n_to_dxdy(1));
645 }
646 use constant _NumSeq_Turn4_min_is_infimum => 1; # approaches straight ahead
647  
648 use constant _NumSeq_Turn_oeis_anum =>
649 { '' =>
650 { 'Left' => 'A000012', # left always, all ones
651 'LSR' => 'A000012',
652 # OEIS-Other: A000012 planepath=ArchimedeanChords
653 # OEIS-Other: A000012 planepath=ArchimedeanChords turn_type=LSR
654 },
655 };
656 }
657 { package Math::PlanePath::MultipleRings;
658  
659 # step=1 and step=2 are mostly 1 for left, but after a while each ring
660 # endpoint is to the right
661  
662 sub _NumSeq_Turn_Left_non_decreasing {
663 my ($self) = @_;
664 # step=0 always straight
665 # step=1 straight,straight, then always left
666 return ($self->{'step'} <= 1);
667 }
668 *_NumSeq_Turn_Right_non_decreasing = \&_NumSeq_Turn_Left_non_decreasing;
669 *_NumSeq_Turn_LSR_non_decreasing = \&_NumSeq_Turn_Left_non_decreasing;
670 *_NumSeq_Turn_SLR_non_decreasing = \&_NumSeq_Turn_Left_non_decreasing;
671 *_NumSeq_Turn_SRL_non_decreasing = \&_NumSeq_Turn_Left_non_decreasing;
672  
673 sub _NumSeq_Turn_Turn4_max {
674 my ($self) = @_;
675 my $step = $self->{'step'};
676 return ($step == 0
677 ? 0 # step == 0 is always straight ahead
678 : 4/$step);
679 }
680  
681 use constant _NumSeq_Turn_oeis_anum =>
682 {
683 # MultipleRings step=0 is trivial X=N,Y=0
684 'step=0,ring_shape=circle' =>
685 { Left => 'A000004', # all-zeros
686 LSR => 'A000004', # all zeros, straight
687 # OEIS-Other: A000004 planepath=MultipleRings,step=0
688 # OEIS-Other: A000004 planepath=MultipleRings,step=0 turn_type=LSR
689 },
690 'step=0,ring_shape=polygon' =>
691 { Left => 'A000004', # all-zeros
692 LSR => 'A000004', # all zeros, straight
693 # OEIS-Other: A000004 planepath=MultipleRings,step=0,ring_shape=polygon
694 # OEIS-Other: A000004 planepath=MultipleRings,step=0,ring_shape=polygon turn_type=LSR
695 },
696 };
697 }
698 { package Math::PlanePath::PixelRings;
699 # has right turns between rings
700 use constant _NumSeq_Turn_Turn4_max => 3.5;
701 }
702 { package Math::PlanePath::FilledRings;
703 use constant _NumSeq_Turn_Turn4_max => 3.5;
704 }
705 { package Math::PlanePath::Hypot;
706 sub _NumSeq_Turn4_min_is_infimum {
707 my ($self) = @_;
708 return ($self->{'points'} eq 'all');
709 }
710 {
711 my %_NumSeq_Turn_Turn4_max
712 = (all => 1.5, # at N=2, apparent maximum
713 even => 1.5, # at N=2, apparent maximum
714 odd => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(3,-3, 3,5),
715 );
716 sub _NumSeq_Turn_Turn4_max {
717 my ($self) = @_;
718 return ($_NumSeq_Turn_Turn4_max{$self->{'points'}} || 0);
719 }
720 }
721 }
722 { package Math::PlanePath::HypotOctant;
723 # apparently approaches +360 degrees
724 use constant _NumSeq_Turn4_max_is_supremum => 1;
725 }
726 { package Math::PlanePath::TriangularHypot;
727 # points=even Turn4=0 at N=31
728 #
729 # points=all apparently approaches 0
730 # min i=473890[1303230202] 0.00000 px=-11,py=1 dx=-13,dy=1 -13.000
731 #
732 # points=odd apparently approaches 0
733 # min i=95618[113112002] 0.01111 px=-14,py=4 dx=-16,dy=4 -4.000
734 #
735 # points=hex apparently approaches 0
736 # min i=44243[22303103] 0.01111 px=-15,py=3 dx=-12,dy=2 -6.000
737 #
738 # points=hex_rotated Turn4=0 at N=58
739 # points=hex_centred Turn4=0 at N=24
740 {
741 my %_NumSeq_Turn4_min_is_infimum = (all => 1,
742 odd => 1,
743 hex => 1,
744 );
745 sub _NumSeq_Turn4_min_is_infimum {
746 my ($self) = @_;
747 return ($_NumSeq_Turn4_min_is_infimum{$self->{'points'}} || 0);
748 }
749 }
750 {
751 my %_NumSeq_Turn_Turn4_max
752 = (even => 1.5, # at N=2
753 odd => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(5,3, 0,-6),
754 all => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(5,3, 0,-6),
755 hex => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(2,0, -3,1),
756 hex_rotated => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(1,1, -3,-1),
757 hex_centred => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(3,1, -2,2),
758 );
759 sub _NumSeq_Turn_Turn4_max {
760 my ($self) = @_;
761 return ($_NumSeq_Turn_Turn4_max{$self->{'points'}} || 0);
762 }
763 }
764 }
765 # { package Math::PlanePath::PythagoreanTree;
766 # # A000004 all-zeros and A000012 all-ones are OFFSET=0 which doesn't match
767 # # start N=1 here for always turn left or right in UAD.
768 # }
769 # { package Math::PlanePath::RationalsTree;
770 # # SB turn cf A021913 0,0,1,1
771 # # A133872 1,1,0,0
772 # # A057077 1,1,-1,-1
773 # # A087960 1,-1,-1,1
774 # # HCS turn left close to A010059 thue-morse or A092436
775 # # right A010060
776 # # LSR => 'A106400', # thue-morse +/-1
777 # # CfracDigits radix=1 likewise
778 # }
779 # { package Math::PlanePath::FractionsTree;
780 # }
781 # { package Math::PlanePath::ChanTree;
782 # # FIXME: k=4,5,6 are Right-only, maybe
783 # # sub _NumSeq_Turn_Left_max {
784 # # my ($self) = @_;
785 # # return ($self->{'k'} >= 4
786 # # ? 0 # never Left
787 # # : 1);
788 # # }
789 # # sub _NumSeq_Turn_Right_min {
790 # # my ($self) = @_;
791 # # return ($self->{'k'} >= 4
792 # # ? 1 # always Right
793 # # : 0);
794 # # }
795 # # sub _NumSeq_Turn_LSR_max {
796 # # my ($self) = @_;
797 # # return ($self->{'k'} >= 4
798 # # ? -1 # always Right
799 # # : 1);
800 # # }
801 # }
802 { package Math::PlanePath::DiagonalRationals;
803 sub _NumSeq_Turn_Turn4_max {
804 my ($self) = @_;
805 return ($self->{'direction'} eq 'down'
806 ? 2.5 # N=2
807 : Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-1,1, 2,-1)); # N=3
808 }
809 }
810 # { package Math::PlanePath::FactorRationals;
811 # # revbinary
812 # # max i=296[10220] 3.98889 px=-258,py=1 dx=-26,dy=1[-122,1] -26.000
813 # N=295=5*59 X=5*59 Y=1 N=297
814 # N=296=2^3*37 X=37 Y=2 -26,+1 \ N=296 <-------- N=295
815 # N=297=3^3*11 X=11 Y=3 -258,+1
816 # }
817 { package Math::PlanePath::GcdRationals;
818 # Turn4 minimum
819 # pairs_order=rows
820 # min=0 at N=12
821 # max i=216[3120] 3.98889 px=11,py=-14 dx=3,dy=-4[3,-10] -0.750
822 #
823 # pairs_order=rows_reverse
824 # min i=13[31] 0.00000 px=-1,py=0 dx=-1,dy=0 0.000
825 # max i=611[21203] 3.98889 px=-1,py=2 dx=-13,dy=28[-31,130] -0.464
826 #
827 # pairs_order=diagonals_down
828 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
829 # max i=561[20301] 3.98889 px=-7,py=8 dx=-5,dy=6[-11,12] -0.833
830 #
831 # pairs_order=diagonals_up
832 # min i=11[23] 0.00000 px=-1,py=1 dx=-1,dy=1 -1.000
833 # max i=4886[1030112] 3.98889 px=6,py=-6 dx=15,dy=-16[33,-100] -0.938
834 #
835 # Are these exact maximums or more when bigger N?
836 }
837 # { package Math::PlanePath::CfracDigits;
838 # }
839 { package Math::PlanePath::AR2W2Curve; # NSEW+diag
840 use constant _NumSeq_Turn_Turn4_max => 3.5;
841 }
842 { package Math::PlanePath::PeanoCurve;
843 use constant _NumSeq_Turn_oeis_anum =>
844 { 'radix=3' =>
845 {
846 # 2---0---0---0---0---2
847 # | |
848 # 2---0---1 1---0---2
849 # | |
850 # .---0---1 1---0---0-...
851 SLR => 'A163536', # turn 0=ahead,1=left,2=right, OFFSET=1
852 SRL => 'A163537',
853 # OEIS-Catalogue: A163536 planepath=PeanoCurve turn_type=SLR
854 # OEIS-Catalogue: A163537 planepath=PeanoCurve turn_type=SRL
855  
856 # Not quite, A039963 is OFFSET=0 vs first turn N=1 here
857 # Straight => 'A039963',
858 },
859 };
860 }
861 # { package Math::PlanePath::WunderlichSerpentine;
862 # }
863 { package Math::PlanePath::HilbertCurve;
864 use constant _NumSeq_Turn_oeis_anum =>
865 { '' =>
866 { SLR => 'A163542', # relative direction ahead=0,left=1,right=2 OFFSET=1
867 SRL => 'A163543', # relative direction transpose
868 # OEIS-Catalogue: A163542 planepath=HilbertCurve turn_type=SLR
869 # OEIS-Catalogue: A163543 planepath=HilbertCurve turn_type=SRL
870 },
871 };
872 }
873 { package Math::PlanePath::HilbertSides;
874 use constant _NumSeq_Turn_oeis_anum =>
875 { '' =>
876 { NotStraight => 'A035263', # morphism
877 # main A035263 is KochCurve turn
878 # OEIS-Other: A035263 planepath=HilbertSides turn_type=NotStraight
879  
880 # Not quite, OFFSET=0 but first turn here N=1.
881 # # OEIS-Other: A096268 planepath=HilbertSides turn_type=Straight
882 # Straight => 'A096268', # odd/even trailing 0 bits
883 },
884 };
885 }
886 { package Math::PlanePath::ZOrderCurve;
887 sub _NumSeq_Turn_Turn4_min {
888 my ($self) = @_;
889 return ($self->{'radix'} == 2
890 ? 0.5
891 : 0); # includes straight
892 }
893 # radix max at
894 # ----- ------
895 # 2 3 *---* Y=radix-1
896 # 3 8 \
897 # 4 15 \
898 # 5 24 * Y=0
899 sub _NumSeq_Turn_Turn4_max {
900 my ($self) = @_;
901 return (Math::NumSeq::PlanePathTurn::_turn_func_Turn4
902 (1,0, 1,1-$self->{'radix'}));
903 }
904 }
905 { package Math::PlanePath::GrayCode;
906 # ENHANCE-ME: check this is true
907 # PlanePathTurn planepath=GrayCode,apply_type=TsF,gray_type=reflected,radix=2, turn_type=SLR
908 # PlanePathTurn planepath=GrayCode,apply_type=Fs,gray_type=reflected,radix=2, turn_type=SLR
909 # match 1,1,0,0,1,1,1,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,1,1,1
910 # A039963 The period-doubling sequence A035263 repeated.
911 # A039963 ,1,1,0,0,1,1,1,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,1,1,1
912  
913 # Not quite, A039963 is OFFSET=0 vs first turn at N=1 here
914 # 'Math::PlanePath::GrayCode' =>
915 # {
916 # Left => 'A039963', # duplicated KochCurve
917 # LSR => 'A039963',
918 # },
919 # Koch characteristic of A003159 ending even zeros
920 # 'Math::PlanePath::GrayCode' =>
921  
922 use constant _NumSeq_Turn_oeis_anum =>
923 {
924 do {
925 my $peano = Math::PlanePath::PeanoCurve
926 -> _NumSeq_Turn_oeis_anum -> {'radix=3'};
927 ('apply_type=TsF,gray_type=reflected,radix=3' => $peano,
928 'apply_type=FsT,gray_type=reflected,radix=3' => $peano,
929 ),
930 # OEIS-Other: A163536 planepath=GrayCode,apply_type=TsF,radix=3 turn_type=SLR
931 # OEIS-Other: A163536 planepath=GrayCode,apply_type=FsT,radix=3 turn_type=SLR
932 # OEIS-Other: A163537 planepath=GrayCode,apply_type=TsF,radix=3 turn_type=SRL
933 # OEIS-Other: A163537 planepath=GrayCode,apply_type=FsT,radix=3 turn_type=SRL
934 },
935 };
936 }
937 # { package Math::PlanePath::ImaginaryBase;
938 # }
939 # { package Math::PlanePath::ImaginaryHalf;
940 # }
941 # { package Math::PlanePath::CubicBase;
942 # }
943 # { package Math::PlanePath::Flowsnake;
944 # # inherit from FlowsnakeCentres
945 # }
946 { package Math::PlanePath::FlowsnakeCentres;
947 use constant _NumSeq_Turn_Turn4_max => 3.5;
948 }
949 # { package Math::PlanePath::GosperIslands;
950 # }
951 { package Math::PlanePath::KochCurve;
952 use constant _NumSeq_Turn_oeis_anum =>
953 { '' =>
954 { Left => 'A035263', # OFFSET=1 matches N=1
955 # OEIS-Catalogue: A035263 planepath=KochCurve
956  
957 SLR => 'A056832',
958 # OEIS-Catalogue: A056832 planepath=KochCurve turn_type=SLR
959 # A056832 All a(n) = 1 or 2; a(1) = 1; get next 2^k terms by repeating first 2^k terms and changing last element so sum of first 2^(k+1) terms is odd.
960 # A056832 ,1,2,1,1,1,2,1,2,1,2,1,1,1,2,1
961  
962 # Not quite, A096268 OFFSET=0 values 0,1,0,0,0,1
963 # whereas here N=1 first turn values 0,1,0,0,0,1
964 # Right => 'A096268', # morphism
965 },
966 };
967 }
968 # { package Math::PlanePath::KochPeaks;
969 # }
970 # { package Math::PlanePath::KochSnowflakes;
971 # }
972 # { package Math::PlanePath::KochSquareflakes;
973 # }
974 # { package Math::PlanePath::QuadricCurve;
975 # }
976 # { package Math::PlanePath::QuadricIslands;
977 # }
978 { package Math::PlanePath::SierpinskiTriangle;
979 {
980 my %_NumSeq_Turn_Turn4_max = (triangular => 2.5,
981 left => 2.5,
982 right => 3,
983 diagonal => 2.5,
984 );
985 sub _NumSeq_Turn_Turn4_max {
986 my ($self) = @_;
987 return $_NumSeq_Turn_Turn4_max{$self->{'align'}};
988 }
989 }
990 }
991 { package Math::PlanePath::SierpinskiArrowhead;
992 use constant _NumSeq_Turn_Turn4_min => 0.5; # North-East diagonal
993 use constant _NumSeq_Turn_Turn4_max => 3.5; # South-East diagonal
994 }
995 { package Math::PlanePath::SierpinskiArrowheadCentres;
996 use constant _NumSeq_Turn_Turn4_max => 3.5; # South-East diagonal
997 }
998 # { package Math::PlanePath::SierpinskiCurve;
999 # # use constant _NumSeq_Turn_oeis_anum =>
1000 # # { 'arms=1' =>
1001 # # {
1002 # # # Not quite, A039963 numbered OFFSET=0 whereas first turn at N=1 here
1003 # # Right => 'A039963', # duplicated KochCurve turns
1004 # # },
1005 # # },
1006 # # }
1007 # }
1008 { package Math::PlanePath::SierpinskiCurveStair;
1009 use constant _NumSeq_Turn_Turn4_min => 1; # never straight
1010 }
1011 { package Math::PlanePath::DragonCurve;
1012 use constant _NumSeq_Turn_Turn4_min => 1; # left or right only
1013 use constant _NumSeq_Turn_oeis_anum =>
1014 { 'arms=1' =>
1015 {
1016 'LSR' => 'A034947', # Jacobi symbol (-1/n)
1017 # OEIS-Catalogue: A034947 planepath=DragonCurve turn_type=LSR
1018  
1019 Turn4 => 'A099545', # (odd part of n) mod 4
1020 # OEIS-Catalogue: A099545 planepath=DragonCurve turn_type=Turn4
1021  
1022 # 'L1R0' => 'A014577', # left=1,right=0 OFFSET=0
1023 # 'L0R1' => 'A014707', # left=0,right=1 OFFSET=0
1024 # 'L1R2' => 'A014709', # left=1,right=2 OFFSET=0
1025 # 'L1R3' => 'A099545', # left=1,right=3 OFFSET=1
1026  
1027 # # Not quite, A014707 has OFFSET=0 cf first elem for N=1
1028 # Left => 'A014707', # turn, 1=left,0=right
1029 # # OEIS-Catalogue: A014707 planepath=DragonCurve
1030  
1031 # # Not quite, A014577 has OFFSET=0 cf first elem for N=1
1032 # Right => 'A014577', # turn, 0=left,1=right
1033 # # OEIS-Catalogue: A014577 planepath=DragonCurve turn_type=Right
1034  
1035 # Not quite A014709 OFFSET=0 vs first turn at N=1 here
1036 # SLR => 'A014709'
1037 # SRL => 'A014710',
1038 },
1039 };
1040 }
1041 { package Math::PlanePath::DragonRounded;
1042 use constant _NumSeq_Turn_Turn4_min => 0.5;
1043 use constant _NumSeq_Turn_Turn4_max => 3.5;
1044 }
1045 # { package Math::PlanePath::DragonMidpoint;
1046 # }
1047 { package Math::PlanePath::AlternatePaper;
1048 use constant _NumSeq_Turn_Turn4_min => 1; # left or right only
1049  
1050 # A209615 is (-1)^e for each p^e prime=4k+3 or prime=2
1051 # 3*3 mod 4 = 1 mod 4
1052 # so picks out bit above lowest 1-bit, and factor -1 if an odd power-of-2
1053 # which is the AlternatePaper turn formula
1054 #
1055 use constant _NumSeq_Turn_oeis_anum =>
1056 { 'arms=1' =>
1057 { LSR => 'A209615',
1058 # OEIS-Catalogue: A209615 planepath=AlternatePaper turn_type=LSR
1059 Right => 'A292077',
1060 # OEIS-Catalogue: A292077 planepath=AlternatePaper turn_type=Right
1061  
1062 # # Not quite, A106665 has OFFSET=0 cf first here i=1
1063 # 'Left' => 'A106665', # turn, 1=left,0=right
1064 # # OEIS-Catalogue: A106665 planepath=AlternatePaper i_offset=1
1065 },
1066 };
1067 }
1068 { package Math::PlanePath::GosperSide;
1069  
1070 # Suspect not in OEIS:
1071 # Left or Right according to lowest non-zero ternary digit 1 or 2
1072 #
1073 use constant _NumSeq_Turn_oeis_anum =>
1074 { '' =>
1075 { Left => 'A137893', # turn, 1=left,0=right, OFFSET=1
1076 SLR => 'A060236', # base-3 lowest non-zero digit 1=left,2=right
1077 # OEIS-Catalogue: A137893 planepath=GosperSide
1078 # OEIS-Other: A137893 planepath=TerdragonCurve
1079 # OEIS-Catalogue: A060236 planepath=GosperSide turn_type=SLR
1080 # OEIS-Other: A060236 planepath=TerdragonCurve turn_type=SLR
1081 # A060236 would also be a "TTurn3"
1082  
1083 # cf A136442 - a(3n)=1, a(3n-1)=0, a(3n+1)=a(n)
1084 # ternary lowest non-1 0->1 2->0
1085  
1086 # Not quite, A080846 OFFSET=0 values 0,1,0,0,1 which are N=1 here
1087 # Right => 'A080846',
1088 # # OEIS-Catalogue: A080846 planepath=GosperSide turn_type=Right
1089 # # OEIS-Other: A080846 planepath=TerdragonCurve turn_type=Right
1090 # Or A189640 has extra initial 0.
1091 },
1092 };
1093 }
1094 { package Math::PlanePath::TerdragonCurve;
1095 # GosperSide and TerdragonCurve same turn sequence, by diff angles
1096 use constant _NumSeq_Turn_Turn4_min => 1;
1097 use constant _NumSeq_Turn_Turn4_max => 3;
1098 use constant _NumSeq_Turn_oeis_anum =>
1099 { 'arms=1' => Math::PlanePath::GosperSide->_NumSeq_Turn_oeis_anum->{''} };
1100 }
1101 { package Math::PlanePath::TerdragonRounded;
1102 use constant _NumSeq_Turn_Turn4_min => 0.5;
1103 use constant _NumSeq_Turn_Turn4_max => 3.5;
1104 }
1105 { package Math::PlanePath::TerdragonMidpoint;
1106 use constant _NumSeq_Turn_Turn4_max => 3;
1107 }
1108 { package Math::PlanePath::AlternateTerdragon;
1109 use constant _NumSeq_Turn_Turn4_min => 1;
1110 use constant _NumSeq_Turn_Turn4_max => 3;
1111 # use constant _NumSeq_Turn_oeis_anum =>
1112 # { 'arms=1' =>
1113 # {
1114 # # Not quite, A156595 OFFSET=0, whereas here N=1 first turn
1115 # # Right => 'A156595',
1116 # },
1117 # };
1118 }
1119 { package Math::PlanePath::R5DragonCurve;
1120 use constant _NumSeq_Turn_Turn4_min => 1; # right or left turn always
1121 # # Not quite, OFFSET=0 values 0,0,1,1,0
1122 # # cf first turn here N=1 values 0,0,1,1,0
1123 # # 'Math::PlanePath::R5DragonCurve' =>
1124 # # { Right => 'A175337',
1125 # # # OEIS-Catalogue: A175337 planepath=R5DragonCurve turn_type=Right
1126 # # },
1127 }
1128 # { package Math::PlanePath::R5DragonMidpoint;
1129 # }
1130 { package Math::PlanePath::CCurve;
1131 use constant _NumSeq_Turn_oeis_anum =>
1132 { '' =>
1133 { NotStraight => 'A035263',
1134 # main A035263 is KochCurve turn
1135 # OEIS-Other: A035263 planepath=CCurve turn_type=NotStraight
1136 },
1137 # Not quite, A096268 OFFSET=1 vs first turn N=1 here
1138 # Straight => 'A096268'
1139 };
1140 }
1141 # { package Math::PlanePath::ComplexPlus;
1142 # }
1143 { package Math::PlanePath::ComplexMinus;
1144 # use constant _NumSeq_Turn_oeis_anum =>
1145 # { 'realpart=1' =>
1146 # {
1147 # # Not quite, A011658 OFFSET=0 vs first turn N=1 here
1148 # # NotStraight => 'A011658', # repeat 0,0,0,1,1
1149 # # # OEIS-Other: A011658 planepath=ComplexMinus turn_type=NotStraight
1150 # },
1151 # };
1152 }
1153 # { package Math::PlanePath::ComplexRevolving;
1154 # }
1155 { package Math::PlanePath::Rows;
1156 # 3---4 width=2
1157 # \ N=2 turn4=1.5
1158 # 1---2 N=3 turn4=2.5
1159 sub _NumSeq_Turn_Turn4_min {
1160 my ($self) = @_;
1161 return ($self->{'width'} == 2
1162 ? 1.5 # at N=2
1163 : 0); # otherwise has straight points
1164 }
1165 # *--------
1166 # \---\
1167 # *---------*
1168 sub _NumSeq_Turn_Turn4_max {
1169 my ($self) = @_;
1170 return ($self->{'width'} <= 1
1171 ? 0 # width=1 always straight
1172 : (Math::NumSeq::PlanePathTurn::_turn_func_Turn4
1173 (1-$self->{'width'},1, 1,0))); # at row start
1174 }
1175  
1176 use constant _NumSeq_Turn_oeis_anum =>
1177 {
1178 'n_start=1,width=0' => # Rows width=0 is trivial X=N,Y=0
1179 { Left => 'A000004', # all-zeros
1180 LSR => 'A000004', # all zeros, straight
1181 # OEIS-Other: A000004 planepath=Rows,width=0
1182 # OEIS-Other: A000004 planepath=Rows,width=0 turn_type=LSR
1183 },
1184  
1185 # 4 N=1 turn=2
1186 # \ N=2 turn=4
1187 # 2---3
1188 # \
1189 # 0---1
1190 'n_start=-1,width=2' =>
1191 { TTurn6 => 'A010694', # repeat 2,4 with OFFSET=0
1192 # OEIS-Other: A010694 planepath=Rows,width=2,n_start=-1 turn_type=TTurn6
1193 },
1194 };
1195 }
1196 { package Math::PlanePath::Columns;
1197 # 2 4 height=2
1198 # | \ | N=2 turn4=2.5
1199 # 1 3 N=3 turn4=1.5
1200 sub _NumSeq_Turn_Turn4_min {
1201 my ($self) = @_;
1202 return ($self->{'height'} == 2
1203 ? 1.5 # at N=3
1204 : 0); # otherwise has straight points
1205 }
1206 # *
1207 # | \
1208 # | |
1209 # * *
1210 sub _NumSeq_Turn_Turn4_max {
1211 my ($self) = @_;
1212 return ($self->{'height'} <= 1
1213 ? 0 # height=1 always straight
1214 : (Math::NumSeq::PlanePathTurn::_turn_func_Turn4
1215 (0,1, 1,1-$self->{'height'}))); # at column top
1216 }
1217  
1218 use constant _NumSeq_Turn_oeis_anum =>
1219 {
1220 'n_start=1,height=0' => # Columns height=0 is trivial X=N,Y=0
1221 { Left => 'A000004', # all-zeros
1222 LSR => 'A000004', # all zeros, straight
1223 # OEIS-Other: A000004 planepath=Columns,height=0
1224 # OEIS-Other: A000004 planepath=Columns,height=0 turn_type=LSR
1225 },
1226  
1227 # 'n_start=-1,height=4' =>
1228 # { Straight => 'A133872', # repeat 1,1,0,0 OFFSET=0
1229 # NotStraight => 'A021913', # repeat 0,0,1,1 OFFSET=0
1230 # # OEIS-Other: A133872 planepath=Columns,n_start=-1,height=4 turn_type=Straight
1231 # # OEIS-Other: A021913 planepath=Columns,n_start=-1,height=4 turn_type=NotStraight
1232 # },
1233 };
1234 }
1235 { package Math::PlanePath::Diagonals;
1236 {
1237 my %_NumSeq_Turn_Turn4_max
1238 = (down => 2.5,
1239 # at N=3 dx=-1,dy=+1 then dx=2,dy=-1
1240 up => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-1,1, 2,-1));
1241 sub _NumSeq_Turn_Turn4_max {
1242 my ($self) = @_;
1243 return $_NumSeq_Turn_Turn4_max{$self->{'direction'}};
1244 }
1245 }
1246  
1247 use constant _NumSeq_Turn_oeis_anum =>
1248 { 'direction=down,n_start=0,x_start=0,y_start=0' =>
1249 { Left => 'A129184', # shift of triangle
1250 SRL => 'A156319', # triangle 1, 2, 0, 0, 0, ... in each row OFFSET=1
1251 # OEIS-Catalogue: A129184 planepath=Diagonals,n_start=0
1252 # OEIS-Catalogue: A156319 planepath=Diagonals,n_start=0 turn_type=SRL
1253 },
1254 'direction=down,n_start=-1,x_start=0,y_start=0' =>
1255 { Right => 'A023531', # 1 at m(m+3)/2
1256 # OEIS-Other: A023531 planepath=Diagonals,n_start=-1 turn_type=Right
1257 },
1258  
1259 'direction=up,n_start=0,x_start=0,y_start=0' =>
1260 { Right => 'A129184', # shift of triangle
1261 SLR => 'A156319', # triangle 1, 2, 0, 0, 0, ... in each row OFFSET=1
1262 # OEIS-Other: A129184 planepath=Diagonals,direction=up,n_start=0 turn_type=Right
1263 # OEIS-Other: A156319 planepath=Diagonals,direction=up,n_start=0 turn_type=SLR
1264 },
1265  
1266 'direction=down,n_start=-1,x_start=0,y_start=0' =>
1267 { NotStraight => 'A097806',
1268 # OEIS-Catalogue: A097806 planepath=Diagonals,n_start=-1 turn_type=NotStraight
1269 },
1270 'direction=up,n_start=-1,x_start=0,y_start=0' =>
1271 { Left => 'A023531', # 1 at m(m+3)/2
1272 # OEIS-Other: A023531 planepath=Diagonals,direction=up,n_start=-1
1273
1274 NotStraight => 'A097806', # OFFSET=0
1275 # OEIS-Other: A097806 planepath=Diagonals,direction=up,n_start=-1 turn_type=NotStraight
1276 },
1277 };
1278 }
1279 { package Math::PlanePath::DiagonalsAlternating;
1280 use constant _NumSeq_Turn_Turn4_max => 3.5;
1281 }
1282 { package Math::PlanePath::DiagonalsOctant;
1283 sub _NumSeq_Turn_Turn4_max {
1284 my ($self) = @_;
1285 return ($self->{'direction'} eq 'down'
1286 ? 2.5 # N=3
1287 : 3); # N=2
1288 }
1289 # # down is left or straight, but also right at N=2,3,4
1290 # # up is straight or right, but also left at N=2,3,4
1291 # 'Math::PlanePath::DiagonalsOctant,direction=down' =>
1292 # { Left => square or pronic starting from 1
1293 # },
1294 # 'Math::PlanePath::DiagonalsOctant,direction=up' =>
1295 # { Left => square or pronic starting from 1
1296 # },
1297 }
1298 { package Math::PlanePath::Staircase;
1299 use constant _NumSeq_Turn_Turn4_min => 1;
1300 use constant _NumSeq_Turn_Turn4_max => 3;
1301 }
1302 # { package Math::PlanePath::StaircaseAlternating;
1303 # }
1304 { package Math::PlanePath::MPeaks;
1305 use constant _NumSeq_Turn_Turn4_max => 3;
1306 }
1307 { package Math::PlanePath::Corner;
1308 use constant _NumSeq_Turn_Turn4_max => 3;
1309  
1310 use constant _NumSeq_Turn_oeis_anum =>
1311 { 'wider=1,n_start=-1' =>
1312 { Left => 'A000007', # turn Left=1 at N=0 only
1313 # catalogued only unless/until a better implementation
1314 # OEIS-Catalogue: A000007 planepath=Corner,wider=1,n_start=-1
1315 },
1316 'wider=2,n_start=-1' =>
1317 { Left => 'A063524', # turn Left=1 at N=1 only
1318 # catalogued only unless/until a better implementation
1319 # OEIS-Catalogue: A063524 planepath=Corner,wider=2,n_start=-1
1320 },
1321 'wider=3,n_start=-1' =>
1322 { Left => 'A185012', # turn Left=1 at N=2 only
1323 # catalogued only unless/until a better implementation
1324 # OEIS-Catalogue: A185012 planepath=Corner,wider=3,n_start=-1
1325 },
1326 # A185013 Characteristic function of three.
1327 # A185014 Characteristic function of four.
1328 # A185015 Characteristic function of 5.
1329 # A185016 Characteristic function of 6.
1330 # A185017 Characteristic function of 7.
1331 };
1332 }
1333 { package Math::PlanePath::PyramidRows;
1334 # if step==0 then always straight ahead
1335  
1336 # *--* *---*
1337 # | step=1 \ step=3
1338 # * *
1339 sub _NumSeq_Turn_Turn4_max {
1340 my ($self) = @_;
1341 return ($self->{'step'} == 0
1342 ? 0 # straight vertical only
1343 # at N=2
1344 : (Math::NumSeq::PlanePathTurn::_turn_func_Turn4
1345 (- $self->{'left_slope'},1, 1,0)));
1346 }
1347  
1348 use constant _NumSeq_Turn_oeis_anum =>
1349 {
1350 # PyramidRows step=0 is trivial X=N,Y=0
1351 do {
1352 my $href= { Left => 'A000004', # all-zeros, OFFSET=0
1353 LSR => 'A000004', # all zeros straight
1354 };
1355 ('step=0,align=centre,n_start=1' => $href,
1356 'step=0,align=right,n_start=1' => $href,
1357 'step=0,align=left,n_start=1' => $href,
1358 );
1359 # OEIS-Other: A000004 planepath=PyramidRows,step=0
1360 # OEIS-Other: A000004 planepath=PyramidRows,step=0 turn_type=LSR
1361 # OEIS-Other: A000004 planepath=PyramidRows,step=0,align=right
1362 # OEIS-Other: A000004 planepath=PyramidRows,step=0,align=left turn_type=LSR
1363 },
1364  
1365 # PyramidRows step=1
1366 do {
1367 my $href= { Left => 'A129184', # triangle 1s shift right
1368 };
1369 ('step=1,align=centre,n_start=0' => $href,
1370 'step=1,align=right,n_start=0' => $href,
1371 'step=1,align=left,n_start=0' => $href,
1372 );
1373 # OEIS-Other: A129184 planepath=PyramidRows,step=1,n_start=0
1374 # OEIS-Other: A129184 planepath=PyramidRows,step=1,align=right,n_start=0
1375 # OEIS-Other: A129184 planepath=PyramidRows,step=1,align=left,n_start=0
1376 },
1377 do {
1378 my $href= { Right => 'A023531', # 1 at n==m*(m+3)/2
1379 };
1380 ('step=1,align=centre,n_start=-1' => $href,
1381 'step=1,align=right,n_start=-1' => $href,
1382 );
1383 # OEIS-Other: A023531 planepath=PyramidRows,step=1,n_start=-1 turn_type=Right
1384 # OEIS-Other: A023531 planepath=PyramidRows,step=1,align=right,n_start=-1 turn_type=Right
1385 },
1386 };
1387 }
1388 { package Math::PlanePath::PyramidSides;
1389 use constant _NumSeq_Turn_Turn4_max => 3; # at N=3
1390 }
1391 { package Math::PlanePath::CellularRule;
1392 sub _NumSeq_Turn_Left_increasing {
1393 my ($self) = @_;
1394 return (defined $self->{'rule'}
1395 && ($self->{'rule'} & 0x17) == 0 # single cell only
1396 ? 1
1397 : 0);
1398 }
1399 *_NumSeq_Turn_Right_increasing = \&_NumSeq_Turn_Left_increasing;
1400  
1401 sub _NumSeq_Turn_LSR_increasing {
1402 my ($self) = @_;
1403 return (defined $self->{'rule'}
1404 && ($self->{'rule'} & 0x17) == 0 # single cell only
1405 ? 1
1406 : 0);
1407 }
1408 }
1409 { package Math::PlanePath::CellularRule::Line;
1410 use constant _NumSeq_Turn_Turn4_max => 0;
1411 use constant _NumSeq_Turn_Turn4_integer => 1;
1412 }
1413 { package Math::PlanePath::CellularRule::OneTwo;
1414  
1415 # 5-6 5--6
1416 # \ |
1417 # 4 left rule=6 4 right rule=20
1418 # ^----. N=2 turn4=2.5 / N=2 turn4=0.5
1419 # 2--3 N=3 turn4=3.5 2--3 N=3 turn4=3
1420 # \ N=4 turn4= |
1421 # 1 1
1422 sub _NumSeq_Turn_Turn4_min {
1423 my ($self) = @_;
1424 return ($self->{'align'} eq 'left'
1425 ? Math::NumSeq::PlanePathTurn::_turn_func_Turn4(1,0, -2,1) # N=3
1426 : 0.5);
1427 }
1428 sub _NumSeq_Turn_Turn4_max {
1429 my ($self) = @_;
1430 return ($self->{'align'} eq 'left'
1431 ? Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-2,1, -1,1) # N=4
1432 : 3);
1433 }
1434  
1435 use constant _NumSeq_Turn_oeis_anum =>
1436 { 'align=left,n_start=-1' =>
1437 { SRL => 'A131534', # repeat 1,2,1, 1,2,1, ... OFFSET=0
1438 # OEIS-Catalogue: A131534 planepath=CellularRule,rule=6,n_start=-1 turn_type=SRL
1439 # OEIS-Other: A131534 planepath=CellularRule,rule=38,n_start=-1 turn_type=SRL
1440 # OEIS-Other: A131534 planepath=CellularRule,rule=134,n_start=-1 turn_type=SRL
1441 # OEIS-Other: A131534 planepath=CellularRule,rule=166,n_start=-1 turn_type=SRL
1442 },
1443  
1444 'align=right,n_start=-1' =>
1445 { SRL => 'A130196', # repeat 1,2,2, 1,2,2, ... OFFSET=0
1446 # OEIS-Catalogue: A130196 planepath=CellularRule,rule=20,n_start=-1 turn_type=SRL
1447 # OEIS-Other: A130196 planepath=CellularRule,rule=52,n_start=-1 turn_type=SRL
1448 # OEIS-Other: A130196 planepath=CellularRule,rule=148,n_start=-1 turn_type=SRL
1449 # OEIS-Other: A130196 planepath=CellularRule,rule=180,n_start=-1 turn_type=SRL
1450 },
1451 };
1452 }
1453 { package Math::PlanePath::CellularRule::Two;
1454  
1455 # 5--6 6--7
1456 # ^---. |
1457 # 4--5 left rule=6 4--5 right rule=84
1458 # ^----. N=2 turn4=2.5 | N=2 turn4=1
1459 # 2--3 N=3 turn4= 2--3 N=3 turn4=3
1460 # \ |
1461 # 1 1
1462 sub _NumSeq_Turn_Turn4_min {
1463 my ($self) = @_;
1464 return ($self->{'align'} eq 'left'
1465 ? Math::NumSeq::PlanePathTurn::_turn_func_Turn4(1,0, -2,1) # N=3
1466 : 1);
1467 }
1468 sub _NumSeq_Turn_Turn4_max {
1469 my ($self) = @_;
1470 return ($self->{'align'} eq 'left'
1471 ? 2.5
1472 : 3);
1473 }
1474 use constant _NumSeq_Turn_oeis_anum =>
1475 { 'align=right,n_start=-1' =>
1476 {
1477 # right line 2, stair step
1478 # |
1479 # 3--1
1480 # |
1481 # 3--1 Turn4 amounts
1482 # |
1483 # *
1484 Turn4 => 'A176040', # 3,1 repeating OFFSET=0
1485 },
1486 # OEIS-Catalogue: A176040 planepath=CellularRule,rule=84,n_start=-1 turn_type=Turn4
1487 # OEIS-Other: A176040 planepath=CellularRule,rule=116,n_start=-1 turn_type=Turn4
1488 # OEIS-Other: A176040 planepath=CellularRule,rule=212,n_start=-1 turn_type=Turn4
1489 # OEIS-Other: A176040 planepath=CellularRule,rule=244,n_start=-1 turn_type=Turn4
1490 };
1491 }
1492 { package Math::PlanePath::CellularRule::OddSolid;
1493 use constant _NumSeq_Turn_Turn4_max => 2.5; # at N=2
1494  
1495 # R 0 0 L 1 0 0 2
1496 # R 0 L 1 0 2
1497 # R L 1 2
1498 # . .
1499  
1500 use constant _NumSeq_Turn_oeis_anum =>
1501 { 'n_start=0' =>
1502 { SRL => 'A156319', # triangle rows 1,2,0,0,0,0,...
1503 # OEIS-Other: A156319 planepath=CellularRule,rule=50,n_start=0 turn_type=SRL
1504 # OEIS-Other: A156319 planepath=CellularRule,rule=58,n_start=0 turn_type=SRL
1505 # OEIS-Other: A156319 planepath=CellularRule,rule=250,n_start=0 turn_type=SRL
1506 # OEIS-Other: A156319 planepath=CellularRule,rule=179,n_start=0 turn_type=SRL
1507 },
1508 };
1509 }
1510 { package Math::PlanePath::CellularRule54;
1511 use constant _NumSeq_Turn_Turn4_max => 2.5;
1512 }
1513 { package Math::PlanePath::CellularRule57;
1514 sub _NumSeq_Turn_Turn4_max {
1515 my ($self) = @_;
1516 return ($self->{'mirror'}
1517 ? 3.5
1518 : Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-2,1, 2,0)); # N=2
1519 }
1520 }
1521 { package Math::PlanePath::CellularRule190;
1522 use constant _NumSeq_Turn_Turn4_max => 2.5;
1523 }
1524 # { package Math::PlanePath::CoprimeColumns;
1525 # }
1526 # { package Math::PlanePath::DivisibleColumns;
1527 # }
1528 # { package Math::PlanePath::File;
1529 # # File points from a disk file
1530 # # FIXME: analyze points for min/max etc
1531 # }
1532 { package Math::PlanePath::QuintetCurve;
1533 use constant _NumSeq_Turn_Turn4_max => 3;
1534 }
1535 { package Math::PlanePath::QuintetCentres;
1536 use constant _NumSeq_Turn_Turn4_max => 3.5;
1537 }
1538 # { package Math::PlanePath::QuintetSide;
1539 # PlanePathTurn planepath=QuintetSide, turn_type=SLR
1540 # match 1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,2,1,2,1,1,2,2,1,2
1541 # A060236 If n mod 3 = 0 then a(n)=a(n/3), otherwise a(n)=n mod 3.
1542 # A060236 ,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,2,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,2,1,2,1,1,2,2,1,2,2,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,2,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,1,1,2,1,1,2,2,1,2,2,1,2,1,1,2,2,
1543 # }
1544 # { package Math::PlanePath::DekkingCurve;
1545 # }
1546 # { package Math::PlanePath::DekkingCentres;
1547 # }
1548 # { package Math::PlanePath::CincoCurve;
1549 # }
1550 { package Math::PlanePath::CornerReplicate;
1551 use constant _NumSeq_Turn_Turn4_min => # apparent minimum
1552 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-1,0, -2,-1); # at N=11
1553 use constant _NumSeq_Turn_Turn4_max => 3; # apparent maximum
1554 }
1555 { package Math::PlanePath::SquareReplicate;
1556 use constant _NumSeq_Turn_Turn4_max =>
1557 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(2,1, 0,1); # at N=9
1558 }
1559 { package Math::PlanePath::DigitGroups;
1560 # radix=3 "11110222222" len many 1s, 2*len-2 many 2s gives ever-increasing
1561 # radix=4 "1303333...3333" ever-increasing
1562 }
1563 { package Math::PlanePath::FibonacciWordFractal;
1564  
1565 use constant _NumSeq_Turn_oeis_anum =>
1566 { '' =>
1567 { SRL => 'A156596', # turns 0=straight,1=right,2=left
1568 # OEIS-Catalogue: A156596 planepath=FibonacciWordFractal turn_type=SRL
1569  
1570 # Not quite, A003849 OFFSET=0 vs first turn N=1 here
1571 # Straight => 'A003849'
1572 },
1573 };
1574 }
1575 # { package Math::PlanePath::LTiling;
1576 # }
1577 { package Math::PlanePath::WythoffArray;
1578 use constant _NumSeq_Turn_Turn4_max => # apparent maximum
1579 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-2,3, 5,-4); # at N=12
1580 }
1581 { package Math::PlanePath::WythoffPreliminaryTriangle;
1582 # apparent maximum, searched through to N=10_000_000
1583 # turn4 = 3.17777777777778
1584 use constant _NumSeq_Turn_Turn4_max =>
1585 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-54,-16, -8,13); # at N=1344
1586 }
1587 { package Math::PlanePath::PowerArray;
1588  
1589 # Turn4 ...
1590 #
1591 # radix=2
1592 # min i=2[10] 1.50000 px=1,py=0 dx=-1,dy=1 -1.000
1593 # max i=3[11] 2.20000 px=-1,py=1 dx=2,dy=-1[10,-1] -2.000
1594 #
1595 # radix=3
1596 # min i=130[11211] 0.00000 px=-1,py=58 dx=0,dy=1 0.000
1597 # max i=67[2111] 3.98889 px=-1,py=30 dx=0,dy=1[0,1] 0.000
1598 #
1599 # radix=4
1600 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1601 # max i=53[311] 3.98889 px=-1,py=30 dx=0,dy=1[0,1] 0.000
1602 #
1603 # radix=5
1604 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1605 # max i=46[141] 3.98889 px=-1,py=29 dx=0,dy=1[0,1] 0.000
1606 #
1607 # radix=6
1608 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1609 # max i=43[111] 3.98889 px=-1,py=30 dx=0,dy=1[0,1] 0.000
1610 #
1611 # radix=7
1612 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1613 # max i=43[61] 3.98889 px=-1,py=31 dx=0,dy=1[0,1] 0.000
1614 #
1615 # radix=8
1616 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1617 # max i=41[51] 3.98889 px=-1,py=31 dx=0,dy=1[0,1] 0.000
1618 #
1619 # radix=9
1620 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1621 # max i=37[41] 3.98889 px=-1,py=29 dx=0,dy=1[0,1] 0.000
1622 #
1623 # radix=10
1624 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1625 # max i=41[41] 3.98889 px=-1,py=33 dx=0,dy=1[0,1] 0.000
1626 #
1627 # radix=16
1628 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1629 # max i=33[21] 3.98889 px=-1,py=29 dx=0,dy=1[0,1] 0.000
1630 #
1631 # radix=29
1632 # min i=2[2] 0.00000 px=0,py=1 dx=0,dy=1 0.000
1633 # max i=59[21] 3.98889 px=-1,py=55 dx=0,dy=1[0,1] 0.000
1634  
1635 # use constant _NumSeq_oeis_anum =>
1636 # # Not quite, A011765 0,0,0,1 repeating has OFFSET=1
1637 # # cf n_start=1 is first turn at N=2
1638 # # Left => 'A011765',
1639 # # Right => 'A011765',
1640 #
1641 # # Not quite, A131534 has OFFSET=1 vs first turn at N=2 here
1642 # # 'radix=3' =>
1643 # # { SRL => 'A131534', # repeat 1,2,1, OFFSET=0
1644 # # }
1645 #
1646 # # Not quite, A007877 has OFFSET=1 vs first turn at N=2 here
1647 # # 'radix=4' =>
1648 # # { SRL => 'A007877', # repeat 0,1,2,1
1649 # # }
1650 #
1651 # # Not quite, 0,0,2,1,2 here vs A053796 0,2,1,2,0
1652 # # 'radix=5' =>
1653 # # { SRL => 'A053796', # repeat 0,2,1,2,0
1654 # # }
1655 # };
1656 }
1657 { package Math::PlanePath::ToothpickTree;
1658 {
1659 my %_NumSeq_Turn_Turn4_max
1660 = (wedge => 3, # at N=1 turn right
1661 );
1662 sub _NumSeq_Turn_Turn4_max {
1663 my ($self) = @_;
1664 return $_NumSeq_Turn_Turn4_max{$self->{'parts'}} || 4;
1665 }
1666 }
1667 {
1668 my %_NumSeq_Turn4_max_is_supremum
1669 = (wedge => 0,
1670 );
1671 sub _NumSeq_Turn4_max_is_supremum {
1672 my ($self) = @_;
1673 my $ret = $_NumSeq_Turn4_max_is_supremum{$self->{'parts'}};
1674 return (defined $ret ? $ret : 1);
1675 }
1676 }
1677 }
1678 { package Math::PlanePath::ToothpickReplicate;
1679 {
1680 my %_NumSeq_Turn_Turn4_max
1681 = ( # at N=16
1682 '3' => Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-1,3, 0,1),
1683 );
1684 sub _NumSeq_Turn_Turn4_max {
1685 my ($self) = @_;
1686 return $_NumSeq_Turn_Turn4_max{$self->{'parts'}} || 3.5;
1687 }
1688 }
1689 }
1690 { package Math::PlanePath::ToothpickUpist;
1691 use constant _NumSeq_Turn_Turn4_max =>
1692 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-2,1, 2,0); # at N=4
1693 }
1694 { package Math::PlanePath::ToothpickSpiral;
1695 use constant _NumSeq_Turn_Turn4_min => 1; # left or right always
1696 }
1697 { package Math::PlanePath::LCornerReplicate;
1698 # min i=63[333] 0.25556 px=1,py=0 dx=7,dy=3 2.333
1699 use constant _NumSeq_Turn_Turn4_min =>
1700 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(1,0, 7,3); # at N=63
1701  
1702 # higher N=1333..3333[base4] loop 3.8, 2.8, 1.7888, 0.7888
1703 # max i=8191[1333333] 3.80000 px=-1,py=0 dx=-38,dy=13[-212,31] -2.923
1704 use constant _NumSeq_Turn_Turn4_max =>
1705 Math::NumSeq::PlanePathTurn::_turn_func_Turn4(-1,0, -38,13); # at N=8191
1706 }
1707 { package Math::PlanePath::LCornerTree;
1708 # parts=3 maybe maximum
1709 # max i=3107[300203] 3.98889 px=1,py=0 dx=66,dy=-1[1002,-1] -66.000
1710  
1711 # LCornerTree,parts=diagonal-1 Turn4 values_max=4 vs saw_values_max=3 at i=27 (to i_end=801)
1712  
1713 {
1714 my %_NumSeq_Turn_Turn4_max
1715 = (wedge => 3, # at N=14
1716 'wedge+1' => 3, # at N=19
1717 diagonal => 3, # at N=21
1718 'diagonal-1' => 3, # at N=27
1719 );
1720 sub _NumSeq_Turn_Turn4_max {
1721 my ($self) = @_;
1722 return $_NumSeq_Turn_Turn4_max{$self->{'parts'}} || 4;
1723 }
1724 }
1725 {
1726 my %_NumSeq_Turn4_max_is_supremum
1727 = (4 => 0, # apparently
1728 );
1729 sub _NumSeq_Turn4_max_is_supremum {
1730 my ($self) = @_;
1731 return $_NumSeq_Turn4_max_is_supremum{$self->{'parts'}};
1732 }
1733 }
1734 }
1735  
1736 1;
1737 __END__