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