| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # geometry of space: value range checks, normalisation and computing distance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Graphics::Toolkit::Color::Space::Shape; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 50 | ▶ | use v5.12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 50 | ▶ | use Graphics::Toolkit::Color::Space::Basis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 50 | ▶ | use Graphics::Toolkit::Color::Space::Util qw/round_decimals is_nr/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | #### constructor ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 583 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=28 SCAR=33.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 583 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 583 | my ($basis, $type, $range, $precision, $constraint) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 583 | ▶ | return unless ref $basis eq 'Graphics::Toolkit::Color::Space::Basis'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # expand axis type definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 582 | ▶ | if (not defined $type){ $type = [ (1) x $basis->axis_count ] } # set all axis as linear per default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ▶ | elsif (ref $type eq 'ARRAY' and @$type == $basis->axis_count ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
ref $type eq "ARRAY" and @$type == $basis->axis_count
MC/DC100%2/2
ref $type eq "ARRAY" and @$type == $basis->axis_count
ref $type eq "ARRAY"
@$type == $basis->axis_count
Truth table100%3/3
A and B
A= ref $type eq "ARRAY"B= @$type == $basis->axis_count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 185 | for my $i ($basis->axis_iterator) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 553 | my $atype = $type->[$i]; # type def of this axis | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 553 | ▶ | return unless defined $atype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 553 | ▶ | if ($atype eq 'angular' or $atype eq 'circular' or $atype eq '0') { $type->[$i] = 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$atype eq "angular" or $atype eq "circular" or $atype eq 0
$atype eq "angular" or $atype eq "circular"
MC/DC100%3/3
$atype eq "angular" or $atype eq "circular" or $atype eq 0
$atype eq "angular"
$atype eq "circular"
$atype eq 0
Truth table100%4/4
A or B or C
A= $atype eq "angular"B= $atype eq "circular"C= $atype eq 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 360 | ▶ | elsif ($atype eq 'linear' or $atype eq '1') { $type->[$i] = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$atype eq "linear" or $atype eq 1
MC/DC100%2/2
$atype eq "linear" or $atype eq 1
$atype eq "linear"
$atype eq 1
Truth table100%3/3
A or B
A= $atype eq "linear"B= $atype eq 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | elsif ($atype eq 'no' or $atype eq '2') { $type->[$i] = 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$atype eq "no" or $atype eq 2
MC/DC100%2/2
$atype eq "no" or $atype eq 2
$atype eq "no"
$atype eq 2
Truth table100%3/3
A or B
A= $atype eq "no"B= $atype eq 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | else { return 'invalid axis type at element '.$i.'. It has to be "angular", "linear" or "no".' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | } else { return 'invalid axis type definition in color space '.$basis->space_name } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 578 | $range = expand_range_definition(undef, $basis, $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 578 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 570 | $precision = expand_precision_definition( $basis, $precision ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 570 | ▶ | return $precision unless ref $precision; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # check constraint def | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 568 | ▶ | if (defined $constraint){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 74 | ▶ | return 'color space constraint definition has to be a none empty HASH ref' if ref $constraint ne 'HASH' or not %$constraint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $constraint ne "HASH" or not %$constraint
MC/DC100%2/2
ref $constraint ne "HASH" or not %$constraint
ref $constraint ne "HASH"
not %$constraint
Truth table100%3/3
A or not(B)
A= ref $constraint ne "HASH"B= not %$constraint
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 72 | for my $constraint_name (keys %$constraint){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 73 | my $properties = $constraint->{$constraint_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 73 | ▶ | return 'a color space constraint has to be a HASH ref with three keys' unless ref $properties eq 'HASH' and keys(%$properties) == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $properties eq "HASH" and keys %$properties == 3
MC/DC50%1/2
ref $properties eq "HASH" and keys %$properties == 3
ref $properties eq "HASH"
keys %$properties == 3
Truth table66%2/3
A and B
A= ref $properties eq "HASH"B= keys %$properties == 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 71 | $properties = {%$properties}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 71 | my $error_msg = 'constraint "$constraint_name" in '.$basis->space_name.' color space'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 71 | for (qw/checker error remedy/){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | return $error_msg." needs the string-propertiy '$_'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 207 | ▶ | unless exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_}
exists $properties->{$_} and $properties->{$_}
MC/DC33%1/3
exists $properties->{$_} and $properties->{$_} and not ref $properties->{$_}
exists $properties->{$_}
$properties->{$_}
not ref $properties->{$_}
Truth table50%2/4
A and B and not(C)
A= exists $properties->{$_}B= $properties->{$_}C= not ref $properties->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 68 | $properties->{'checker_code'} = $properties->{'checker'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 68 | $properties->{'checker'} = eval 'sub {'.$properties->{'checker_code'}.'}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 68 | ▶ | return 'checker code of '.$error_msg.":'$properties->{checker_code}' does not eval - $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 68 | $properties->{'remedy_code'} = $properties->{'remedy'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 68 | $properties->{'remedy'} = eval 'sub {'.$properties->{'remedy_code'}.'}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 68 | ▶ | return 'remedy code of '.$error_msg.":'$properties->{remedy_code}' does not eval - $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 68 | $constraint->{ $constraint_name } = $properties; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 494 | } else { $constraint = '' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 561 | bless { basis => $basis, type => $type, range => $range, precision => $precision, constraint => $constraint } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | #### object attribute checker ########################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2300 | ▶ | sub expand_range_definition { # check if range def is valid and eval (expand) it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_range_definition: called CC=29 SCAR=34.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2300 | my ($self, $basis, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2300 | ▶ | $basis = $basis->{'basis'} if ref $basis eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2300 | my $error_msg = 'Bad value range definition!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2300 | ▶ | $range = 1 if not defined $range or $range eq 'normal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $range or $range eq "normal"
MC/DC100%2/2
not defined $range or $range eq "normal"
not defined $range
$range eq "normal"
Truth table100%3/3
not(A) or B
A= not defined $rangeB= $range eq "normal"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2300 | ▶ | $range = 100 if $range eq 'percent'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2300 | ▶ | return $error_msg." It has to be 'normal', 'percent', a number or ARRAY of numbers (by axis position) or HASH (by axis name).'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not ref $range and is_nr($range) or ref $range eq "ARRAY" or ref $range eq "HASH"
not ref $range and is_nr($range) or ref $range eq "ARRAY"
not ref $range and is_nr($range)
MC/DC0%0/4
not ref $range and is_nr($range) or ref $range eq "ARRAY" or ref $range eq "HASH"
not ref $range
is_nr($range)
ref $range eq "ARRAY"
ref $range eq "HASH"
Truth table42%3/7
not(A) and B or C or D
A= not ref $rangeB= is_nr($range)C= ref $range eq "ARRAY"D= ref $range eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ' Instead of a number you can also insert ARRAY with two number!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | unless (not ref $range and is_nr( $range )) or ref $range eq 'ARRAY' or ref $range eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2300 | ▶ | if (ref $range eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 6 | my $range_array = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | for my $axis_name (keys %$range){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 13 | ▶ | next unless $basis->is_axis_name( $axis_name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 13 | $range_array->[ $basis->pos_from_axis_name($axis_name) ] = $range->{$axis_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | for my $axis_index ($basis->axis_iterator){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 18 | ▶ | next if exists $range_array->[$axis_index] and defined $range_array->[$axis_index]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $range_array->[$axis_index] and defined $range_array->[$axis_index]
MC/DC50%1/2
exists $range_array->[$axis_index] and defined $range_array->[$axis_index]
exists $range_array->[$axis_index]
defined $range_array->[$axis_index]
Truth table66%2/3
A and B
A= exists $range_array->[$axis_index]B= defined $range_array->[$axis_index]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | ▶ | next unless ref $self and ref $self->{'range'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self and ref $self->{"range"}
MC/DC50%1/2
ref $self and ref $self->{"range"}
ref $self
ref $self->{"range"}
Truth table66%2/3
A and B
A= ref $selfB= ref $self->{"range"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | $range_array->[$axis_index] = $self->{'range'}[$axis_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | $range = $range_array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2300 | ▶ | $range = [$range] unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2300 | ▶ | $range = [(@$range) x $basis->axis_count] if @$range == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2300 | ▶ | return "Range definition needs inside an ARRAY or HASH a number or pair of them in an ARRAY for each axis!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | if @$range != $basis->axis_count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2296 | for my $axis_index ($basis->axis_iterator) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 6935 | my $axis_range = $range->[$axis_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 6935 | ▶ | if (not ref $axis_range){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3449 | ▶ | if ($axis_range eq 'normal') {$range->[$axis_index] = [0, 1]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | elsif ($axis_range eq 'percent') {$range->[$axis_index] = [0, 100]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3446 | else {$range->[$axis_index] = [0, $axis_range+0]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } elsif (ref $axis_range eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3486 | ▶ | return $error_msg.' Array at axis number '.$axis_index.' has to have two elements' unless @$axis_range == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3484 | ▶ | return $error_msg.' None numeric value at lower bound for axis number '.$axis_index unless is_nr( $axis_range->[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3484 | ▶ | return $error_msg.' None numeric value at upper bound for axis number '.$axis_index unless is_nr( $axis_range->[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3483 | ▶ | return $error_msg.' Lower bound (first value) is >= than upper bound at axis number '.$axis_index if $axis_range->[0] >= $axis_range->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | } else { return "Range definitin for axis $axis_index was not an two element ARRAY!" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2292 | return $range; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4561 | ▶ | sub try_check_range_definition { # check if range def is valid and eval (expand) it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
try_check_range_definition: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4561 | my ($self, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 4561 | ▶ | return $self->{'range'} unless defined $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1722 | return $self->expand_range_definition( $self->{'basis'}, $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 933 | ▶ | sub expand_precision_definition { # check if precision def is valid and eval (exapand) it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_precision_definition: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 933 | my ($basis, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 933 | ▶ | $basis = $basis->{'basis'} if ref $basis eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 933 | ▶ | $precision = -1 unless defined $precision; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 933 | ▶ | $precision = [($precision) x $basis->axis_count] unless ref $precision; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 933 | ▶ | return 'need an ARRAY as definition of axis value precision' unless ref $precision eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 933 | ▶ | return 'definition of axis value precision has to have same lengths as basis' unless @$precision == $basis->axis_count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 931 | return $precision; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1533 | ▶ | sub try_check_precision_definition { # check if range def is valid and eval (expand) it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
try_check_precision_definition: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1533 | my ($self, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1533 | ▶ | return $self->{'precision'} unless defined $precision; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 363 | return expand_precision_definition( $self->{'basis'}, $precision ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | #### getter of space object ############################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 12391 | ▶ | sub basis { $_[0]{'basis'}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
basis: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # per axis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 13151 | ▶ | sub is_axis_numeric { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_axis_numeric: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 13151 | my ($self, $axis_nr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 13151 | ▶ | return 0 if not defined $axis_nr or not exists $self->{'type'}[$axis_nr]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
MC/DC50%1/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr
exists $self->{"type"}[$axis_nr]
Truth table66%2/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 13147 | ▶ | $self->{'type'}[$axis_nr] < 2 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2986 | ▶ | sub is_axis_euclidean { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_axis_euclidean: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2986 | my ($self, $axis_nr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2986 | ▶ | return 0 if not defined $axis_nr or not exists $self->{'type'}[$axis_nr]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
MC/DC50%1/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr
exists $self->{"type"}[$axis_nr]
Truth table66%2/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2985 | ▶ | $self->{'type'}[$axis_nr] == 1 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3052 | ▶ | sub is_axis_angular { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_axis_angular: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3052 | my ($self, $axis_nr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3052 | ▶ | return 0 if not defined $axis_nr or not exists $self->{'type'}[$axis_nr]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
MC/DC50%1/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr
exists $self->{"type"}[$axis_nr]
Truth table66%2/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 3051 | ▶ | $self->{'type'}[$axis_nr] == 0 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 18 | ▶ | sub axis_value_max { # --> +value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
axis_value_max: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 18 | my ($self, $axis_nr, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 18 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 18 | ▶ | return undef unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 18 | ▶ | return undef unless $self->is_axis_numeric($axis_nr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 17 | return $range->[$axis_nr][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | ▶ | sub axis_value_min { # --> +value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
axis_value_min: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | my ($self, $axis_nr, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | ▶ | return undef unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | return undef unless $self->is_axis_numeric($axis_nr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | return $range->[$axis_nr][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 16 | ▶ | sub axis_value_precision { # --> +precision? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
axis_value_precision: called CC=7 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 16 | my ($self, $axis_nr, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 16 | ▶ | return undef if not defined $axis_nr or not exists $self->{'type'}[$axis_nr]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $axis_nr and exists $self->{"type"}[$axis_nr]
MC/DC0%0/2
defined $axis_nr and exists $self->{"type"}[$axis_nr]
defined $axis_nr
exists $self->{"type"}[$axis_nr]
Truth table33%1/3
A and B
A= defined $axis_nrB= exists $self->{"type"}[$axis_nr]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 16 | ▶ | return undef unless $self->is_axis_numeric($axis_nr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 15 | ▶ | $precision //= $self->{'precision'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$precision //= $self->{"precision"}
MC/DC0%0/2
$precision //= $self->{"precision"}
$precision
$self->{"precision"}
Truth table33%1/3
A //= B
A= $precisionB= $self->{"precision"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 15 | ▶ | return undef unless ref $precision eq 'ARRAY' and exists $precision->[$axis_nr]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $precision eq "ARRAY" and exists $precision->[$axis_nr]
MC/DC0%0/2
ref $precision eq "ARRAY" and exists $precision->[$axis_nr]
ref $precision eq "ARRAY"
exists $precision->[$axis_nr]
Truth table33%1/3
A and B
A= ref $precision eq "ARRAY"B= exists $precision->[$axis_nr]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 15 | $precision->[$axis_nr]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # all axis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 36 | ▶ | sub is_euclidean { # all axis linear ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_euclidean: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 36 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 36 | ▶ | map { return 0 if $self->{'type'}[$_] != 1 } $self->basis->axis_iterator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 24 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 36 | ▶ | sub is_cylindrical { # one axis angular, rest linear ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_cylindrical: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 36 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 36 | my $angular_axis = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 36 | ▶ | map { $angular_axis++ if $self->{'type'}[$_] == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 109 | ▶ | return 0 if $self->{'type'}[$_] > 1; } $self->basis->axis_iterator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 35 | ▶ | return ($angular_axis == 1) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | sub is_int_valued { # all ranges int valued ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_int_valued: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | ▶ | map { return 0 if $self->{'precision'}[$_] != 0 } $self->basis->axis_iterator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1388 | ▶ | sub has_constraints { my ($self) = @_; return (ref $self->{'constraint'}) ? 1 : 0 } # --> ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_constraints: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | #### value checker ##################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 373 | ▶ | sub check_value_shape { # @tuple -- $range, $precision --> $@vals | ~! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_value_shape: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 373 | my ($self, $tuple, $range, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 373 | ▶ | return 'color value tuple in '.$self->basis->space_name.' space needs to be ARRAY ref with '.$self->basis->axis_count.' elements' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | unless $self->basis->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 303 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 303 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 303 | $precision = $self->try_check_precision_definition( $precision ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 303 | ▶ | return $precision unless ref $precision; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 303 | my @names = $self->basis->long_axis_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 303 | for my $axis_index ($self->basis->axis_iterator){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 696 | ▶ | next unless $self->is_axis_numeric( $axis_index ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 696 | ▶ | return $names[$axis_index]." value is below minimum of ".$range->[$axis_index][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | if $tuple->[$axis_index] < $range->[$axis_index][0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 596 | ▶ | return $names[$axis_index]." value is above maximum of ".$range->[$axis_index][1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | if $tuple->[$axis_index] > $range->[$axis_index][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 492 | ▶ | return $names[$axis_index]." value is not properly rounded " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$precision->[$axis_index] >= 0 and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
MC/DC100%2/2
$precision->[$axis_index] >= 0 and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
$precision->[$axis_index] >= 0
round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
Truth table100%3/3
A and B
A= $precision->[$axis_index] >= 0B= round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | if $precision->[$axis_index] >= 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | and round_decimals($tuple->[$axis_index], $precision->[$axis_index]) != $tuple->[$axis_index]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 80 | ▶ | if ($self->has_constraints){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 11 | my $tuple = $self->normalize($tuple, $range); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 11 | for my $constraint (values %{$self->{'constraint'}}){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 11 | ▶ | return $constraint->{'error'} unless $constraint->{'checker'}->( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 78 | return $tuple; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | ▶ | sub is_equal { # @tuple_a, @tuple_b -- $precision --> ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_equal: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 8 | my ($self, $tuple_a, $tuple_b, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 8 | ▶ | return 0 unless $self->basis->is_value_tuple( $tuple_a ) and $self->basis->is_value_tuple( $tuple_b ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->basis->is_value_tuple($tuple_a) and $self->basis->is_value_tuple($tuple_b)
MC/DC100%2/2
$self->basis->is_value_tuple($tuple_a) and $self->basis->is_value_tuple($tuple_b)
$self->basis->is_value_tuple($tuple_a)
$self->basis->is_value_tuple($tuple_b)
Truth table100%3/3
A and B
A= $self->basis->is_value_tuple($tuple_a)B= $self->basis->is_value_tuple($tuple_b)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | $precision = $self->try_check_precision_definition( $precision ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | for my $axis_nr ($self->basis->axis_iterator) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 9 | ▶ | return 0 if round_decimals($tuple_a->[$axis_nr], $precision->[$axis_nr]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | != round_decimals($tuple_b->[$axis_nr], $precision->[$axis_nr]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | ▶ | sub is_in_constraints { # @tuple --> ? # normalized values only, so it works on any ranges | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_constraints: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | my ($self, $tuple) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | ▶ | return 0 unless $self->basis->is_number_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | ▶ | return 1 unless $self->has_constraints; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | for my $constraint (values %{$self->{'constraint'}}){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | return 0 unless $constraint->{'checker'}->( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | sub is_in_bounds { # @tuple --> ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_bounds: called CC=6 SCAR=18.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | my ($self, $tuple, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | return 0 unless $self->is_in_linear_bounds( $tuple, $range ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | for my $axis_nr ($self->basis->axis_iterator) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | ▶ | next if $self->{'type'}[$axis_nr]; # skip none linear axis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | return 0 if $tuple->[$axis_nr] < $range->[$axis_nr][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
MC/DC0%0/2
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
$tuple->[$axis_nr] < $range->[$axis_nr][0]
$tuple->[$axis_nr] > $range->[$axis_nr][1]
Truth table33%1/3
A or B
A= $tuple->[$axis_nr] < $range->[$axis_nr][0]B= $tuple->[$axis_nr] > $range->[$axis_nr][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | or $tuple->[$axis_nr] > $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 380 | ▶ | sub is_in_linear_bounds { # @tuple --> ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_linear_bounds: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 380 | my ($self, $tuple, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 380 | ▶ | return 0 unless $self->basis->is_number_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 377 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 377 | for my $axis_nr ($self->basis->axis_iterator) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1062 | ▶ | next if $self->{'type'}[$axis_nr] != 1; # skip none linear axis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 978 | ▶ | return 0 if $tuple->[$axis_nr] < $range->[$axis_nr][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
MC/DC100%2/2
$tuple->[$axis_nr] < $range->[$axis_nr][0] or $tuple->[$axis_nr] > $range->[$axis_nr][1]
$tuple->[$axis_nr] < $range->[$axis_nr][0]
$tuple->[$axis_nr] > $range->[$axis_nr][1]
Truth table100%3/3
A or B
A= $tuple->[$axis_nr] < $range->[$axis_nr][0]B= $tuple->[$axis_nr] > $range->[$axis_nr][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | or $tuple->[$axis_nr] > $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 298 | ▶ | if ($self->has_constraints){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return $self->is_in_constraints( $self->normalize( $tuple, $range) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 298 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | #### value ops ######################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 995 | ▶ | sub clamp { # change values if outside of range to nearest boundary, angles get rotated into range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clamp: called CC=15 SCAR=27.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 995 | my ($self, $tuple, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 995 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 995 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 995 | ▶ | $tuple = [] unless ref $tuple eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 995 | ▶ | pop @$tuple while @$tuple > $self->basis->axis_count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 995 | $tuple = [@$tuple]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 995 | for my $axis_nr ($self->basis->axis_iterator){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 3003 | ▶ | next unless $self->is_axis_numeric( $axis_nr ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3003 | ▶ | if (not defined $tuple->[$axis_nr]){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 80 | my $default_value = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 80 | ▶ | $default_value = $range->[$axis_nr][0] if $default_value < $range->[$axis_nr][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
MC/DC50%1/2
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
$default_value < $range->[$axis_nr][0]
$default_value > $range->[$axis_nr][1]
Truth table66%2/3
A or B
A= $default_value < $range->[$axis_nr][0]B= $default_value > $range->[$axis_nr][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | or $default_value > $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 80 | $tuple->[$axis_nr] = $default_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2923 | ▶ | next unless $self->is_axis_euclidean( $axis_nr ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2698 | ▶ | $tuple->[$axis_nr] = $range->[$axis_nr][0] if $tuple->[$axis_nr] < $range->[$axis_nr][0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2698 | ▶ | $tuple->[$axis_nr] = $range->[$axis_nr][1] if $tuple->[$axis_nr] > $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 995 | $tuple = $self->rotate($tuple, $range); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 995 | ▶ | if ($self->has_constraints){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 29 | $tuple = $self->normalize( $tuple, $range); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 29 | for my $constraint (values %{$self->{'constraint'}}){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 29 | ▶ | $tuple = $constraint->{'remedy'}->($tuple) unless $constraint->{'checker'}->( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 29 | $tuple = $self->denormalize( $tuple, $range); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 995 | return $tuple; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1010 | ▶ | sub rotate { # rotate values of circular dimensions into range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rotate: called CC=11 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1010 | my ($self, $tuple, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1010 | ▶ | return unless $self->basis->is_number_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1010 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1010 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1010 | $tuple = [@$tuple]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1010 | for my $axis_nr ($self->basis->axis_iterator){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 3048 | ▶ | next unless $self->is_axis_angular( $axis_nr ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 244 | ▶ | if (not defined $tuple->[$axis_nr]){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $default_value = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $default_value = $range->[$axis_nr][0] if $default_value < $range->[$axis_nr][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
MC/DC0%0/2
$default_value < $range->[$axis_nr][0] or $default_value > $range->[$axis_nr][1]
$default_value < $range->[$axis_nr][0]
$default_value > $range->[$axis_nr][1]
Truth table0%0/3
A or B
A= $default_value < $range->[$axis_nr][0]B= $default_value > $range->[$axis_nr][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | or $default_value > $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $tuple->[$axis_nr] = $default_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 244 | my $delta = $range->[$axis_nr][1] - $range->[$axis_nr][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 244 | ▶ | $tuple->[$axis_nr] += $delta while $tuple->[$axis_nr] < $range->[$axis_nr][0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 244 | ▶ | $tuple->[$axis_nr] -= $delta while $tuple->[$axis_nr] > $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 244 | ▶ | $tuple->[$axis_nr] = $range->[$axis_nr][0] if $tuple->[$axis_nr] == $range->[$axis_nr][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1010 | return $tuple; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1227 | ▶ | sub round { # $tuple -- $precision --> $tuple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
round: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1227 | my ($self, $tuple, $precision) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1227 | ▶ | return unless $self->basis->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1227 | $precision = $self->try_check_precision_definition( $precision ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1227 | ▶ | return "round got bad precision definition" unless ref $precision; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1227 | ▶ | [ map { ($self->is_axis_numeric( $_ ) and $precision->[$_] >= 0) ? round_decimals ($tuple->[$_], $precision->[$_]) : $tuple->[$_] } $self->basis->axis_iterator ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->is_axis_numeric($_) and $precision->[$_] >= 0
MC/DC50%1/2
$self->is_axis_numeric($_) and $precision->[$_] >= 0
$self->is_axis_numeric($_)
$precision->[$_] >= 0
Truth table66%2/3
A and B
A= $self->is_axis_numeric($_)B= $precision->[$_] >= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # normalisation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 762 | ▶ | sub normalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 762 | my ($self, $tuple, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 762 | ▶ | return unless $self->basis->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 762 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 762 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 762 | ▶ | [ map { ($self->is_axis_numeric( $_ )) ? (($tuple->[$_] - $range->[$_][0]) / ($range->[$_][1]-$range->[$_][0])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | : $tuple->[$_] } $self->basis->axis_iterator ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1053 | ▶ | sub denormalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
denormalize: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1053 | my ($self, $tuple, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1053 | ▶ | return unless $self->basis->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1053 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1053 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1053 | ▶ | return [ map { ($self->is_axis_numeric( $_ )) ? ($tuple->[$_] * ($range->[$_][1]-$range->[$_][0]) + $range->[$_][0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | : $tuple->[$_] } $self->basis->axis_iterator ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 30 | ▶ | sub denormalize_delta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
denormalize_delta: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 30 | my ($self, $delta_values, $range) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 30 | ▶ | return unless $self->basis->is_value_tuple( $delta_values ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 30 | $range = $self->try_check_range_definition( $range ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 30 | ▶ | return $range unless ref $range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 30 | ▶ | [ map { ($self->is_axis_numeric( $_ )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ? ($delta_values->[$_] * ($range->[$_][1]-$range->[$_][0])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | : $delta_values->[$_] } $self->basis->axis_iterator ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 62 | ▶ | sub delta { # @normal_tuple_a, @normal_tuple_b --> @delta_tuple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delta: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 62 | my ($self, $tuple1, $tuple2) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 62 | ▶ | return unless $self->basis->is_value_tuple( $tuple1 ) and $self->basis->is_value_tuple( $tuple2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->basis->is_value_tuple($tuple1) and $self->basis->is_value_tuple($tuple2)
MC/DC100%2/2
$self->basis->is_value_tuple($tuple1) and $self->basis->is_value_tuple($tuple2)
$self->basis->is_value_tuple($tuple1)
$self->basis->is_value_tuple($tuple2)
Truth table100%3/3
A and B
A= $self->basis->is_value_tuple($tuple1)B= $self->basis->is_value_tuple($tuple2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # ignore none numeric dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 56 | ▶ | my @delta = map { $self->is_axis_numeric($_) ? ($tuple2->[$_] - $tuple1->[$_]) : 0 } $self->basis->axis_iterator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 56 | ▶ | [ map { $self->{'type'}[$_] ? $delta[$_] : # adapt to circular dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | $delta[$_] < -0.5 ? ($delta[$_]+1) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | $delta[$_] > 0.5 ? ($delta[$_]-1) : $delta[$_] } $self->basis->axis_iterator ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||