| 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 | package Math::PlanePath::KochelCurve; | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | #use List::Util 'max'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | *max = \&Math::PlanePath::_max; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use vars '$VERSION', '@ISA'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | $VERSION = 128; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Math::PlanePath; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use Math::PlanePath::Base::NSEW; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | @ISA = ('Math::PlanePath::Base::NSEW', | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 'Math::PlanePath'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | use Math::PlanePath::Base::Generic | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | 'is_infinite', | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | 'round_nearest'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | use Math::PlanePath::Base::Digits | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | 'round_down_pow', | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 'digit_split_lowtohigh', | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | 'digit_join_lowtohigh'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # uncomment this to run the ### lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | #use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | use constant n_start => 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | use constant class_x_negative => 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | use constant class_y_negative => 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | *xy_is_visited = \&Math::PlanePath::Base::Generic::xy_is_visited_quad1; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # tables generated by tools/kochel-curve-table.pl | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my @next_state = (63,72, 9, 99, 0,90, 36,99, 0, # 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 36,81,18, 72, 9,99, 45,72, 9, # 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 45,90,27, 81,18,72, 54,81,18, # 18 | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 54,99, 0, 90,27,81, 63,90,27, # 27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 36,81, 0, 72,36,81, 45,90,27, # 36 | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 45,90, 9, 81,45,90, 54,99, 0, # 45 | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 54,99,18, 90,54,99, 63,72, 9, # 54 | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 63,72,27, 99,63,72, 36,81,18, # 63 | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 63,72, 9, 99,90,99, 63,72, 9, # 72 | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 36,81,18, 72,99,72, 36,81,18, # 81 | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 45,90,27, 81,72,81, 45,90,27, # 90 | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 54,99, 0, 90,81,90, 54,99, 0); # 99 | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my @digit_to_x = (0,0,0, 1,2,2, 1,1,2, # 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2,1,0, 0,0,1, 1,2,2, # 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2,2,2, 1,0,0, 1,1,0, # 18 | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0,1,2, 2,2,1, 1,0,0, # 27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2,1,1, 2,2,1, 0,0,0, # 36 | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2,2,1, 1,0,0, 0,1,2, # 45 | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0,1,1, 0,0,1, 2,2,2, # 54 | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0,0,1, 1,2,2, 2,1,0, # 63 | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0,0,0, 1,1,1, 2,2,2, # 72 | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2,1,0, 0,1,2, 2,1,0, # 81 | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2,2,2, 1,1,1, 0,0,0, # 90 | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0,1,2, 2,1,0, 0,1,2); # 99 | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my @digit_to_y = (0,1,2, 2,2,1, 1,0,0, # 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0,0,0, 1,2,2, 1,1,2, # 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2,1,0, 0,0,1, 1,2,2, # 18 | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2,2,2, 1,0,0, 1,1,0, # 27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0,0,1, 1,2,2, 2,1,0, # 36 | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2,1,1, 2,2,1, 0,0,0, # 45 | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2,2,1, 1,0,0, 0,1,2, # 54 | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0,1,1, 0,0,1, 2,2,2, # 63 | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0,1,2, 2,1,0, 0,1,2, # 72 | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0,0,0, 1,1,1, 2,2,2, # 81 | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2,1,0, 0,1,2, 2,1,0, # 90 | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2,2,2, 1,1,1, 0,0,0); # 99 | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | my @xy_to_digit = (0,1,2, 7,6,3, 8,5,4, # 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2,3,4, 1,6,5, 0,7,8, # 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 4,5,8, 3,6,7, 2,1,0, # 18 | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 8,7,0, 5,6,1, 4,3,2, # 27 | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8,7,6, 1,2,5, 0,3,4, # 36 | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 6,5,4, 7,2,3, 8,1,0, # 45 | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 4,3,0, 5,2,1, 6,7,8, # 54 | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0,1,8, 3,2,7, 4,5,6, # 63 | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0,1,2, 5,4,3, 6,7,8, # 72 | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2,3,8, 1,4,7, 0,5,6, # 81 | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 8,7,6, 3,4,5, 2,1,0, # 90 | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 6,5,0, 7,4,1, 8,3,2); # 99 | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my @min_digit = (0,0,0,7,8,7, # 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0,0,0,5,5,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0,0,0,3,4,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1,1,1,3,4,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2,2,2,3,4,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1,1,1,5,5,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2,1,0,0,0,1, # 36 | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2,1,0,0,0,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2,1,0,0,0,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3,3,3,5,7,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4,4,4,5,8,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 3,3,3,6,7,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 4,3,2,2,2,3, # 72 | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4,3,1,1,1,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4,3,0,0,0,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 5,5,0,0,0,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 8,7,0,0,0,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5,5,1,1,1,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 8,5,4,4,4,5, # 108 | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7,5,3,3,3,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0,0,0,1,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0,0,0,1,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0,0,0,1,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 7,6,3,3,3,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 8,1,0,0,0,1, # 144 | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 7,1,0,0,0,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 6,1,0,0,0,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6,2,2,2,3,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6,5,4,4,4,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 7,2,2,2,3,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 6,6,6,7,8,7, # 180 | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5,2,1,1,1,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 4,2,0,0,0,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 4,2,0,0,0,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 4,3,0,0,0,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 5,2,1,1,1,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4,4,4,5,6,5, # 216 | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 3,2,2,2,6,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0,0,0,1,6,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0,0,0,1,7,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0,0,0,1,8,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3,2,2,2,7,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0,0,0,3,4,3, # 252 | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0,0,0,2,4,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0,0,0,2,4,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1,1,1,2,5,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 8,7,6,6,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1,1,1,2,5,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0,0,0,5,6,5, # 288 | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0,0,0,4,6,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0,0,0,3,6,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1,1,1,3,7,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2,2,2,3,8,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1,1,1,4,7,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2,1,0,0,0,1, # 324 | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2,1,0,0,0,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2,1,0,0,0,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3,3,3,4,5,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 8,7,6,6,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3,3,3,4,5,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 8,3,2,2,2,3, # 360 | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 7,3,1,1,1,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 6,3,0,0,0,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 6,4,0,0,0,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 6,5,0,0,0,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 7,4,1,1,1,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 6,6,6,7,8,7, # 396 | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 5,4,3,3,3,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0,0,0,1,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0,0,0,1,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0,0,0,1,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5,4,3,3,3,4); | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | my @max_digit = (0,7,8,8,8,7, # 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1,7,8,8,8,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2,7,8,8,8,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2,6,6,6,5,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2,3,4,4,4,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1,6,6,6,5,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2,2,2,1,0,1, # 36 | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3,6,7,7,7,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4,6,8,8,8,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4,6,8,8,8,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 4,5,8,8,8,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3,6,7,7,7,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 4,4,4,3,2,3, # 72 | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5,6,6,6,2,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8,8,8,7,2,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8,8,8,7,1,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 8,8,8,7,0,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5,6,6,6,1,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 8,8,8,5,4,5, # 108 | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8,8,8,6,4,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 8,8,8,6,4,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 7,7,7,6,3,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0,1,2,2,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7,7,7,6,3,6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 8,8,8,1,0,1, # 144 | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 8,8,8,3,3,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 8,8,8,5,4,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 7,7,7,5,4,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 6,6,6,5,4,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7,7,7,3,3,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6,7,8,8,8,7, # 180 | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6,7,8,8,8,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6,7,8,8,8,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 5,5,5,3,1,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4,4,4,3,0,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5,5,5,2,1,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4,5,6,6,6,5, # 216 | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4,5,7,7,7,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 4,5,8,8,8,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 3,3,8,8,8,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0,1,8,8,8,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3,3,7,7,7,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0,3,4,4,4,3, # 252 | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1,3,5,5,5,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 8,8,8,7,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 8,8,8,7,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 8,8,8,7,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1,2,5,5,5,2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0,5,6,6,6,5, # 288 | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1,5,7,7,7,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 2,5,8,8,8,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2,4,8,8,8,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2,3,8,8,8,3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1,4,7,7,7,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2,2,2,1,0,1, # 324 | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3,4,5,5,5,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 8,8,8,7,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 8,8,8,7,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 8,8,8,7,6,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3,4,5,5,5,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 8,8,8,3,2,3, # 360 | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 8,8,8,4,2,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 8,8,8,5,2,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7,7,7,5,1,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 6,6,6,5,0,5, | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 7,7,7,4,1,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 6,7,8,8,8,7, # 396 | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 6,7,8,8,8,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 6,7,8,8,8,7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 5,5,5,4,3,4, | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0,1,2,2,2,1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 5,5,5,4,3,4); | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # state length 108 in each of 4 tables | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | sub n_to_xy { | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2161 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n_to_xy: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ### KochelCurve n_to_xy(): $n | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2161 | ▶ | if ($n < 0) { return; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2161 | ▶ | if (is_infinite($n)) { return ($n,$n); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2161 | my $int = int($n); | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2161 | $n -= $int; # remaining fraction, preserve possible BigFloat/BigRat | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2161 | my @digits = digit_split_lowtohigh($int,9); | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2161 | my $len = ($int*0 + 3) ** scalar(@digits); # inherit bignum | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ### digits: join(', ',@digits)." count ".scalar(@digits) | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ### $len | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2161 | my $state = 63; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2161 | my $dir = 1; # default if all $digit==8 | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2161 | my $x = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2161 | my $y = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2161 | ▶ | while (@digits) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 6894 | $len /= 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 6894 | $state += (my $digit = pop @digits); | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | 6894 | ▶ | if ($digit != 8) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 6273 | $dir = $state; # lowest non-8 digit | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ### $len | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ### $state | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ### digit_to_x: $digit_to_x[$state] | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ### digit_to_y: $digit_to_y[$state] | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ### next_state: $next_state[$state] | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 6894 | $x += $len * $digit_to_x[$state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | 6894 | $y += $len * $digit_to_y[$state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 6894 | $state = $next_state[$state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ### $dir | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ### frac: $n | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # with $n fractional part | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2161 | return ($n * ($digit_to_x[$dir+1] - $digit_to_x[$dir]) + $x, | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | $n * ($digit_to_y[$dir+1] - $digit_to_y[$dir]) + $y); | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | sub xy_to_n { | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my ($self, $x, $y) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xy_to_n: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | ### KochelCurve xy_to_n(): "$x, $y" | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $x = round_nearest ($x); | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $y = round_nearest ($y); | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if ($x < 0 || $y < 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$x < 0 or $y < 0
MC/DC0%0/2
$x < 0 or $y < 0
$x < 0
$y < 0
Truth table0%0/3
A or B
A= $x < 0B= $y < 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if (is_infinite($x)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (is_infinite($y)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $y; | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my @xdigits = digit_split_lowtohigh ($x, 3); | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my @ydigits = digit_split_lowtohigh ($y, 3); | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $state = 63; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my @ndigits; | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | foreach my $i (reverse 0 .. max($#xdigits,$#ydigits)) { # high to low | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my $ndigit = $xy_to_digit[$state | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$xdigits[$i] || 0
$ydigits[$i] || 0
MC/DC0%0/1
$xdigits[$i] || 0
$xdigits[$i]
MC/DC0%0/1
$ydigits[$i] || 0
$ydigits[$i]
Truth table0%0/2
A
A= $xdigits[$i]
Truth table0%0/2
A
A= $ydigits[$i]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | + 3*($xdigits[$i]||0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | + ($ydigits[$i]||0)]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $ndigits[$i] = $ndigit; | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $state = $next_state[$state+$ndigit]; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return digit_join_lowtohigh (\@ndigits, 9, | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | $x * 0 * $y); # bignum zero | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # exact | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | sub rect_to_n_range { | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | my ($self, $x1,$y1, $x2,$y2) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rect_to_n_range: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | ### KochelCurve rect_to_n_range(): "$x1,$y1, $x2,$y2" | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $x1 = round_nearest ($x1); | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $x2 = round_nearest ($x2); | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $y1 = round_nearest ($y1); | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $y2 = round_nearest ($y2); | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | ($x1,$x2) = ($x2,$x1) if $x1 > $x2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | ($y1,$y2) = ($y2,$y1) if $y1 > $y2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ($x2 < 0 || $y2 < 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$x2 < 0 or $y2 < 0
MC/DC0%0/2
$x2 < 0 or $y2 < 0
$x2 < 0
$y2 < 0
Truth table0%0/3
A or B
A= $x2 < 0B= $y2 < 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return (1, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my ($len, $level) = round_down_pow (max($x2,$y2), 3); | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | ### $len | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ### $level | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if (is_infinite($level)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | return (0, $level); | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # At this point an easy round-up range here would be: | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # return (0, 9*$len*$len-1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $n_min = my $n_max | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | = my $x_min = my $y_min | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | = my $x_max = my $y_max | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | = ($x1 * 0 * $x2 * $y1 * $y2); # inherit bignum 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $min_state = my $max_state = 63; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # x__ 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # xx_ 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # xxx 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # _xx 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # __x 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # _x_ 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | while ($level >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $l2 = 2*$len; | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $x_cmp1 = $x_min + $len; | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $y_cmp1 = $y_min + $len; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $x_cmp2 = $x_min + $l2; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $y_cmp2 = $y_min + $l2; | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | my $digit = $min_digit[4*$min_state # 4*9=36 apart | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | + ($x1 >= $x_cmp2 ? 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | : $x1 >= $x_cmp1 ? ($x2 < $x_cmp2 ? 5 : 3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | : ($x2 < $x_cmp1 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | : $x2 < $x_cmp2 ? 1 : 2)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | + ($y1 >= $y_cmp2 ? 6*4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | : $y1 >= $y_cmp1 ? ($y2 < $y_cmp2 ? 6*5 : 6*3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | : ($y2 < $y_cmp1 ? 6*0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | : $y2 < $y_cmp2 ? 6*1 : 6*2))]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # my $key = 4*$min_state # 4*9=36 apart | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # + ($x1 >= $x_cmp2 ? 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # : $x1 >= $x_cmp1 ? ($x2 < $x_cmp2 ? 5 : 3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # : ($x2 < $x_cmp1 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # : $x2 < $x_cmp2 ? 1 : 2)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # + ($y1 >= $y_cmp2 ? 6*4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # : $y1 >= $y_cmp1 ? ($y2 < $y_cmp2 ? 6*5 : 6*3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # : ($y2 < $y_cmp1 ? 6*0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # : $y2 < $y_cmp2 ? 6*1 : 6*2)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # ### $min_state | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # ### $len | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # ### $l2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # ### $key | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # ### $x_cmp1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # ### $x_cmp2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # ### $digit | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $n_min = 9*$n_min + $digit; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $min_state += $digit; | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $x_min += $len * $digit_to_x[$min_state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $y_min += $len * $digit_to_y[$min_state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $min_state = $next_state[$min_state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $x_cmp1 = $x_max + $len; | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $y_cmp1 = $y_max + $len; | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $x_cmp2 = $x_max + $l2; | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $y_cmp2 = $y_max + $l2; | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my $digit = $max_digit[4*$max_state # 4*9=36 apart | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | + ($x1 >= $x_cmp2 ? 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | : $x1 >= $x_cmp1 ? ($x2 < $x_cmp2 ? 5 : 3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | : ($x2 < $x_cmp1 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | : $x2 < $x_cmp2 ? 1 : 2)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | + ($y1 >= $y_cmp2 ? 6*4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | : $y1 >= $y_cmp1 ? ($y2 < $y_cmp2 ? 6*5 : 6*3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | : ($y2 < $y_cmp1 ? 6*0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | : $y2 < $y_cmp2 ? 6*1 : 6*2))]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # my $key = 4*$max_state # 4*9=36 apart | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # + ($x1 >= $x_cmp2 ? 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # : $x1 >= $x_cmp1 ? ($x2 < $x_cmp2 ? 5 : 3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # : ($x2 < $x_cmp1 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # : $x2 < $x_cmp2 ? 1 : 2)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # + ($y1 >= $y_cmp2 ? 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # : $y1 >= $y_cmp1 ? ($y2 < $y_cmp2 ? 5 : 3) | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # : ($y2 < $y_cmp1 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # : $y2 < $y_cmp2 ? 1 : 2)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # ### $max_state | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # ### $len | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # ### $l2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # ### $x_key | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # ### $key | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # ### $x_max | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # ### $y_max | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # ### $x_cmp1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # ### $x_cmp2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # ### $y_cmp1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # ### $y_cmp2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # ### $digit | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # ### max digit: $max_digit[$key] | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $n_max = 9*$n_max + $digit; | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $max_state += $digit; | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $x_max += $len * $digit_to_x[$max_state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $y_max += $len * $digit_to_y[$max_state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $max_state = $next_state[$max_state]; | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $len = int($len/3); | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $level--; | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return ($n_min, $n_max); | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # level_to_n_range() | ||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | ▶ | use Math::PlanePath::SquareReplicate; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 1 | *level_to_n_range = \&Math::PlanePath::SquareReplicate::level_to_n_range; | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | 1 | *n_to_level = \&Math::PlanePath::SquareReplicate::n_to_level; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||