| 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 --path=KochCurve --lines --scale=10 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # math-image --path=KochCurve --all --scale=10 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # continuous but nowhere differentiable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Sur une Courbe Continue sans Tangente, Obtenue par une Construction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # Géométrique Élémentaire | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # http://www.nku.edu/~curtin/grenouille.html | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # http://www.nku.edu/~curtin/koch_171.jpg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # Cesàro, "Remarques sur la Courbe de von Koch." Atti della | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # R. Accad. della Scienze Fisiche e Matem. Napoli 12, No. 15, 1-12, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # 1905. Reprinted as §228 in Opere scelte, a cura dell'Unione matematica | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # italiana e col contributo del Consiglio nazionale delle ricerche, Vol. 2: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # Geometria, Analisi, Fisica Matematica. Rome: Edizioni Cremonese, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # pp. 464-479, 1964. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Thue-Morse count 1s mod 2 is net direction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Toeplitz first diffs is turn sequence +1 or -1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # J. Ma and J.A. Holdener. When Thue-Morse Meets Koch. In Fractals: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # Complex Geometry, Patterns, and Scaling in Nature and Society, volume 13, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # pages 191-206, 2005. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # http://personal.kenyon.edu/holdenerj/StudentResearch/WhenThueMorsemeetsKochJan222005.pdf | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # F.M. Dekking. On the Distribution of Digits In Arithmetic Sequences. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # In Seminaire de Theorie des Nombres de Bordeaux, volume 12, 1983, pages | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # 3201-3212, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | package Math::PlanePath::KochCurve; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | use List::Util 'sum','first'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | use vars '$VERSION', '@ISA'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | $VERSION = 128; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | use Math::PlanePath; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | @ISA = ('Math::PlanePath'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | *_divrem_mutate = \&Math::PlanePath::_divrem_mutate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | use Math::PlanePath::Base::Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | 'is_infinite', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | 'round_nearest'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | use Math::PlanePath::Base::Digits | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | 'round_down_pow', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'round_up_pow', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'digit_split_lowtohigh', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | ▶ | 'digit_join_lowtohigh'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # uncomment this to run the ### lines | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | use constant n_start => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | use constant class_x_negative => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | use constant class_y_negative => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | use constant diffxy_minimum => 0; # X>=Y octant so X-Y>=0 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | use constant dx_minimum => -2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | use constant dx_maximum => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | use constant dy_minimum => -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | use constant dy_maximum => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | *_UNDOCUMENTED__dxdy_list = \&Math::PlanePath::_UNDOCUMENTED__dxdy_list_six; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | ▶ | use constant absdx_minimum => 1; # never vertical | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | use constant dsumxy_minimum => -2; # diagonals | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | ▶ | use constant dsumxy_maximum => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | use constant ddiffxy_minimum => -2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | use constant ddiffxy_maximum => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ▶ | use constant dir_maximum_dxdy => (1,-1); # South-East | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | ▶ | use constant turn_any_straight => 0; # never straight | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | sub n_to_xy { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1456 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n_to_xy: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ### KochCurve n_to_xy(): $n | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # secret negatives to -.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1456 | ▶ | if (2*$n < -1) { return; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1456 | ▶ | if (is_infinite($n)) { return ($n,$n); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1456 | my $x; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | my $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1456 | my $int = int($n); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1456 | $x = 2 * ($n - $int); # usually positive, but n=-0.5 gives x=-0.5 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1456 | $y = $x * 0; # inherit possible bigrat 0 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1456 | $n = $int; # BigFloat int() gives BigInt, use that | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1456 | my $len = $y+1; # inherit bignum 1 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1456 | foreach my $digit (digit_split_lowtohigh($n,4)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ### at: "$x,$y digit=$digit" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 6196 | ▶ | if ($digit == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } elsif ($digit == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1686 | ($x,$y) = (($x-3*$y)/2 + 2*$len, # rotate +60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ($x+$y)/2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } elsif ($digit == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1674 | ($x,$y) = (($x+3*$y)/2 + 3*$len, # rotate -60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ($y-$x)/2 + $len); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ### assert: $digit==3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1615 | $x += 4*$len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6196 | $len *= 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ### final: "$x,$y" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1456 | return ($x,$y); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub xy_to_n { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5645 | ▶ | my ($self, $x, $y) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xy_to_n: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ### KochPeaks xy_to_n(): "$x, $y" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5645 | $x = round_nearest ($x); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5645 | $y = round_nearest ($y); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5645 | ▶ | if ($y < 0 || $x < 0 || (($x ^ $y) & 1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$y < 0 or $x < 0 or ($x ^ $y) & 1
$y < 0 or $x < 0
MC/DC66%2/3
$y < 0 or $x < 0 or ($x ^ $y) & 1
$y < 0
$x < 0
($x ^ $y) & 1
Truth table75%3/4
A or B or C
A= $y < 0B= $x < 0C= ($x ^ $y) & 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ### neg y or parity different ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 517 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 5128 | ▶ | my ($len,$level) = round_down_pow(($x/2)||1, 3); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$x / 2 || 1
MC/DC100%1/1
$x / 2 || 1
$x / 2
Truth table100%2/2
A
A= $x / 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ### $level | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ### $len | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5128 | ▶ | if (is_infinite($level)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return $level; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5128 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5128 | foreach (0 .. $level) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 16525 | $n *= 4; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ### at: "level=$level len=$len x=$x,y=$y n=$n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 16525 | ▶ | if ($x < 3*$len) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 8607 | ▶ | if ($x < 2*$len) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ### digit 0 ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ### digit 1 ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2437 | $x -= 2*$len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2437 | ($x,$y) = (($x+3*$y)/2, # rotate -60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ($y-$x)/2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2437 | $n += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7918 | $x -= 4*$len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ### digit 2 or 3 to: "x=$x" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7918 | ▶ | if ($x < $y) { # before diagonal | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ### digit 2... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3458 | $x += $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3458 | $y -= $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3458 | ($x,$y) = (($x-3*$y)/2, # rotate +60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ($x+$y)/2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3458 | $n += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | #### digit 3... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4460 | $n += 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 16525 | $len /= 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ### end at: "x=$x,y=$y n=$n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5128 | ▶ | if ($x != 0 || $y != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$x != 0 or $y != 0
MC/DC100%2/2
$x != 0 or $y != 0
$x != 0
$y != 0
Truth table100%3/3
A or B
A= $x != 0B= $y != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4947 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 181 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # level extends to x= 2*3^level | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # level = log3(x/2) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # exact | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | sub rect_to_n_range { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 29 | ▶ | my ($self, $x1,$y1, $x2,$y2) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rect_to_n_range: called CC=6 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ### KochCurve rect_to_n_range(): "$x1,$y1 $x2,$y2" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 29 | $x1 = round_nearest ($x1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 29 | $x2 = round_nearest ($x2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 29 | $y1 = round_nearest ($y1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 29 | $y2 = round_nearest ($y2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 29 | ▶ | if ($x1 > $x2) { ($x1,$x2) = ($x2,$x1); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 29 | ▶ | if ($y1 > $y2) { ($y1,$y2) = ($y2,$y1); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 29 | ▶ | if ($x2 < 0 || $y2 < 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$x2 < 0 or $y2 < 0 or 3 * $y1 > $x2
$x2 < 0 or $y2 < 0
MC/DC0%0/3
$x2 < 0 or $y2 < 0 or 3 * $y1 > $x2
$x2 < 0
$y2 < 0
3 * $y1 > $x2
Truth table25%1/4
A or B or C
A= $x2 < 0B= $y2 < 0C= 3 * $y1 > $x2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | || 3*$y1 > $x2 ) { # above line Y=X/3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return (1,0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # * \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # / \ \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # o-+-* *-+-e \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # 0 3 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # 3*Y+X/2 - (Y!=0) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # *-+-* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # * * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # / \ / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # o-+-* *-+-* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # 0 3 6 X/2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 29 | my ($len, $level) = round_down_pow ($x2/2, 3); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 29 | return _rect_to_n_range_rot ($len, $level, 0, $x1,$y1, $x2,$y2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # (undef, my $level) = round_down_pow ($x2/2, 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # ### $level | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # return (0, 4**($level+1)-1); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | my @dir6_to_dx = (2, 1,-1,-2, -1, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | my @dir6_to_dy = (0, 1, 1, 0, -1,-1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | my @max_digit_to_rot = (1, -2, 1, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | my @min_digit_to_rot = (0, 1, -2, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 4 | my @max_digit_to_offset = (-1, -1, -1, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub _rect_to_n_range_rot { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 29 | ▶ | my ($initial_len, $level_max, $initial_rot, $x1,$y1, $x2,$y2) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rect_to_n_range_rot: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ### KochCurve _rect_to_n_range_rot(): "$x1,$y1 $x2,$y2 len=$initial_len level=$level_max rot=$initial_rot" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 29 | my ($rot, $len, $x, $y); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | my $overlap = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ### overlap: "$x,$y len=$len rot=$rot" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 373 | ▶ | if ($len == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=24 SCAR=31.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 152 | ▶ | return ($x >= $x1 && $x <= $x2 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$x >= $x1 && $x <= $x2 && $y >= $y1 && $y <= $y2
$x >= $x1 and $x <= $x2 and $y >= $y1
$x >= $x1 and $x <= $x2
MC/DC100%4/4
$x >= $x1 && $x <= $x2 && $y >= $y1 && $y <= $y2
$x >= $x1
$x <= $x2
$y >= $y1
$y <= $y2
Truth table100%5/5
A and B and C && D
A= $x >= $x1B= $x <= $x2C= $y >= $y1D= $y <= $y2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | && $y >= $y1 && $y <= $y2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 221 | my $len = $len / 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 221 | ▶ | if ($rot < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 156 | ▶ | if ($rot == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # / \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # o-+-* *-+-. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 77 | ▶ | return ($y <= $y2 # bottom before end | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$y <= $y2 && $y + $len >= $y1 && $x <= $x2 && $x + 6 * $len > $x1
$y <= $y2 and $y + $len >= $y1 and $x <= $x2
$y <= $y2 and $y + $len >= $y1
MC/DC100%4/4
$y <= $y2 && $y + $len >= $y1 && $x <= $x2 && $x + 6 * $len > $x1
$y <= $y2
$y + $len >= $y1
$x <= $x2
$x + 6 * $len > $x1
Truth table100%5/5
A and B and C && D
A= $y <= $y2B= $y + $len >= $y1C= $x <= $x2D= $x + 6 * $len > $x1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | && $y+$len >= $y1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | && $x <= $x2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | && $x+6*$len > $x1); # right before end, exclusive | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } elsif ($rot == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # *-+-* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # * +----- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # / |x1,y2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 53 | ▶ | return ($x <= $x2 # left before end | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$x <= $x2 && $y + 3 * $len > $y1 && $y - $x <= $y2 - $x1
$x <= $x2 and $y + 3 * $len > $y1
MC/DC100%3/3
$x <= $x2 && $y + 3 * $len > $y1 && $y - $x <= $y2 - $x1
$x <= $x2
$y + 3 * $len > $y1
$y - $x <= $y2 - $x1
Truth table100%4/4
A and B && C
A= $x <= $x2B= $y + 3 * $len > $y1C= $y - $x <= $y2 - $x1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | && $y+3*$len > $y1 # top after start, exclusive | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | && $y-$x <= $y2-$x1); # diag before corner | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # . |x1,y1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # \ +----- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # *-+-* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 26 | ▶ | return ($y <= $y2 # bottom before end | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$y <= $y2 && $x - 3 * $len <= $x2 && $y + $x >= $y1 + $x1
$y <= $y2 and $x - 3 * $len <= $x2
MC/DC100%3/3
$y <= $y2 && $x - 3 * $len <= $x2 && $y + $x >= $y1 + $x1
$y <= $y2
$x - 3 * $len <= $x2
$y + $x >= $y1 + $x1
Truth table100%4/4
A and B && C
A= $y <= $y2B= $x - 3 * $len <= $x2C= $y + $x >= $y1 + $x1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | && $x-3*$len <=$x2 # left before end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | && $y+$x >= $y1+$x1); # diag after corner | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 65 | ▶ | if ($rot == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # .-+-* *-+-o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # \ / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 13 | ▶ | return ($y >= $y1 # top after start | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$y >= $y1 && $y - $len <= $y2 && $x >= $x1 && $x - 6 * $len < $x2
$y >= $y1 and $y - $len <= $y2 and $x >= $x1
$y >= $y1 and $y - $len <= $y2
MC/DC100%4/4
$y >= $y1 && $y - $len <= $y2 && $x >= $x1 && $x - 6 * $len < $x2
$y >= $y1
$y - $len <= $y2
$x >= $x1
$x - 6 * $len < $x2
Truth table100%5/5
A and B and C && D
A= $y >= $y1B= $y - $len <= $y2C= $x >= $x1D= $x - 6 * $len < $x2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | && $y-$len <= $y2 # bottom before end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | && $x >= $x1 # right after start | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | && $x-6*$len < $x2); # left before end, exclusive | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } elsif ($rot == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # x2,y1| o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # -----+ / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # *-+-* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 7 | ▶ | return ($x >= $x1 # right after start | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$x >= $x1 && $y - 3 * $len < $y2 && $y - $x >= $y1 - $x2
$x >= $x1 and $y - 3 * $len < $y2
MC/DC100%3/3
$x >= $x1 && $y - 3 * $len < $y2 && $y - $x >= $y1 - $x2
$x >= $x1
$y - 3 * $len < $y2
$y - $x >= $y1 - $x2
Truth table100%4/4
A and B && C
A= $x >= $x1B= $y - 3 * $len < $y2C= $y - $x >= $y1 - $x2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | && $y-3*$len < $y2 # bottom before end, exclusive | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | && $y-$x >= $y1-$x2); # diag after corner | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # *-+-* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # -----+ \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # x2,y2| . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 45 | ▶ | return ($y >= $y1 # top after start | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$y >= $y1 && $x + 3 * $len >= $x1 && $y + $x <= $y2 + $x2
$y >= $y1 and $x + 3 * $len >= $x1
MC/DC100%3/3
$y >= $y1 && $x + 3 * $len >= $x1 && $y + $x <= $y2 + $x2
$y >= $y1
$x + 3 * $len >= $x1
$y + $x <= $y2 + $x2
Truth table100%4/4
A and B && C
A= $y >= $y1B= $x + 3 * $len >= $x1C= $y + $x <= $y2 + $x2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | && $x+3*$len >= $x1 # right after start | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | && $y+$x <= $y2+$x2); # diag before corner | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 29 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 29 | my $zero = 0*$x1*$x2*$y1*$y2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 29 | my @lens = ($initial_len); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 29 | my $n_hi; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 29 | $rot = $initial_rot; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 29 | $len = $initial_len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 29 | $x = $zero; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 29 | $y = $zero; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 29 | my @digits = (4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 29 | for (;;) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 212 | my $digit = --$digits[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ### max at: "digits=".join(',',@digits)." xy=$x,$y len=$len" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 212 | ▶ | if ($digit < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | pop @digits; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | ▶ | if (! @digits) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ### nothing found to level_max ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | return (1, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ### end of digits, backtrack ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | $len = $lens[$#digits]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 210 | my $offset = $max_digit_to_offset[$digit]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 210 | $rot = ($rot - $max_digit_to_rot[$digit]) % 6; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 210 | $x += $dir6_to_dx[$rot] * $offset * $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 210 | $y += $dir6_to_dy[$rot] * $offset * $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | ### $offset | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ### $rot | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 210 | ▶ | if (&$overlap()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 77 | ▶ | if ($#digits >= $level_max) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ### yes overlap, found n_hi ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ### digits: join(',',@digits) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | ### n_hi: _digit_join_hightolow (\@digits, 4, $zero) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 29 | $n_hi = _digit_join_hightolow (\@digits, 4, $zero); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 29 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ### yes overlap, descend ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 48 | push @digits, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 48 | ▶ | $len = ($lens[$#digits] ||= $len/3); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$lens[$#digits] ||= $len / 3
MC/DC0%0/2
$lens[$#digits] ||= $len / 3
$lens[$#digits]
$len / 3
Truth table66%2/3
A ||= B
A= $lens[$#digits]B= $len / 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ### no overlap, next digit ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 29 | $rot = $initial_rot; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 29 | $x = $zero; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 29 | $y = $zero; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 29 | $len = $initial_len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 29 | @digits = (-1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 29 | for (;;) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 167 | my $digit = ++$digits[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ### min at: "digits=".join(',',@digits)." xy=$x,$y len=$len" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 167 | ▶ | if ($digit > 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 4 | pop @digits; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 4 | ▶ | if (! @digits) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ### oops, n_lo not found to level_max ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return (1, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ### end of digits, backtrack ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | $len = $lens[$#digits]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | ### $digit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | ### rot increment: $min_digit_to_rot[$digit] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 163 | $rot = ($rot + $min_digit_to_rot[$digit]) % 6; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 163 | ▶ | if (&$overlap()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 79 | ▶ | if ($#digits >= $level_max) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ### yes overlap, found n_lo ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ### digits: join(',',@digits) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | ### n_lo: _digit_join_hightolow (\@digits, 4, $zero) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 29 | return (_digit_join_hightolow (\@digits, 4, $zero), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $n_hi); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | ### yes overlap, descend ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 50 | push @digits, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 50 | ▶ | $len = ($lens[$#digits] ||= $len/3); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$lens[$#digits] ||= $len / 3
MC/DC0%0/2
$lens[$#digits] ||= $len / 3
$lens[$#digits]
$len / 3
Truth table33%1/3
A ||= B
A= $lens[$#digits]B= $len / 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ### no overlap, next digit ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 84 | $x += $dir6_to_dx[$rot] * $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 84 | $y += $dir6_to_dy[$rot] * $len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # $aref->[0] high digit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | sub _digit_join_hightolow { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 58 | ▶ | my ($aref, $radix, $zero) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_digit_join_hightolow: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 58 | my @lowtohigh = reverse @$aref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 58 | return digit_join_lowtohigh(\@lowtohigh, $radix, $zero); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 4 | my @digit_to_dir = (0, 1, -1, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 4 | my @digit_to_nextturn = (1, # digit=1 (with +1 for "next" N) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | -2, # digit=2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1); # digit=3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | sub n_to_dxdy { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 20 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n_to_dxdy: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ### n_to_dxdy(): $n | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 20 | ▶ | if ($n < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return; # first direction at N=0 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 20 | ▶ | if (is_infinite($n)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | return ($n,$n); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 20 | my $int = int($n); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 20 | $n -= $int; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 20 | my @ndigits = digit_split_lowtohigh($int,4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 20 | my $dir6 = sum(0, map {$digit_to_dir[$_]} @ndigits) % 6; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 20 | my $dx = $dir6_to_dx[$dir6]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 20 | my $dy = $dir6_to_dy[$dir6]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 20 | ▶ | if ($n) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # fraction part | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # lowest non-3 digit, or zero if all 3s (0 above high digit) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 12 | ▶ | $dir6 += $digit_to_nextturn[ first {$_!=3} @ndigits, 0 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 12 | $dir6 %= 6; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 12 | $dx += $n*($dir6_to_dx[$dir6] - $dx); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 12 | $dy += $n*($dir6_to_dy[$dir6] - $dy); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 20 | return ($dx, $dy); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | sub _UNTESTED__n_to_dir6 { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_UNTESTED__n_to_dir6: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if ($n < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return undef; # first direction at N=0 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if (is_infinite($n)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | return ($n,$n); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | return (sum (map {$digit_to_dir[$_]} digit_split_lowtohigh($n,4)) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&sum(map({$digit_to_dir[$_];} digit_split_lowtohigh($n, 4))) || 0
MC/DC0%0/1
&sum(map({$digit_to_dir[$_];} digit_split_lowtohigh($n, 4))) || 0
&sum(map({$digit_to_dir[$_];} digit_split_lowtohigh($n, 4)))
Truth table0%0/2
A
A= &sum(map({$digit_to_dir[$_];} digit_split_lowtohigh($n, 4)))
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | || 0) # if empty | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | % 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 4 | my @n_to_turn6 = (undef, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 1, # +60 degrees | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | -2, # -120 degrees | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1); # +60 degrees | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | sub _UNTESTED__n_to_turn6 { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_UNTESTED__n_to_turn6: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if (is_infinite($n)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | while ($n) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $digit = _divrem_mutate($n,4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ($digit) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # lowest non-zero digit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return $n_to_turn6[$digit]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | sub _UNTESTED__n_to_turn_LSR { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_UNTESTED__n_to_turn_LSR: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | my $turn6 = $self->_UNTESTED__n_to_turn6($n) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_UNTESTED__n_to_turn6($n) || (return undef)
MC/DC0%0/1
$self->_UNTESTED__n_to_turn6($n) || (return undef)
$self->_UNTESTED__n_to_turn6($n)
Truth table0%0/2
A
A= $self->_UNTESTED__n_to_turn6($n)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | return ($turn6 > 0 ? 1 : -1); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | sub _UNTESTED__n_to_turn_left { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_UNTESTED__n_to_turn_left: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | my $turn6 = $self->_UNTESTED__n_to_turn6($n) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_UNTESTED__n_to_turn6($n) || (return undef)
MC/DC0%0/1
$self->_UNTESTED__n_to_turn6($n) || (return undef)
$self->_UNTESTED__n_to_turn6($n)
Truth table0%0/2
A
A= $self->_UNTESTED__n_to_turn6($n)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | return ($turn6 > 0 ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | sub _UNTESTED__n_to_turn_right { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_UNTESTED__n_to_turn_right: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | my $turn6 = $self->_UNTESTED__n_to_turn6($n) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_UNTESTED__n_to_turn6($n) || (return undef)
MC/DC0%0/1
$self->_UNTESTED__n_to_turn6($n) || (return undef)
$self->_UNTESTED__n_to_turn6($n)
Truth table0%0/2
A
A= $self->_UNTESTED__n_to_turn6($n)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | return ($turn6 < 0 ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # levels | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | sub level_to_n_range { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | my ($self, $level) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
level_to_n_range: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | return (0, 4**$level); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | sub n_to_level { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | my ($self, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n_to_level: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if ($n < 0) { return undef; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | if (is_infinite($n)) { return $n; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $n = round_nearest($n); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my ($pow, $exp) = round_up_pow ($n, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | return $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||