3DWorld/Bound.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 47 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
new
2.0
box
2.0
CRAP 2.0
1 package SDL::Tutorial::3DWorld::Bound;
2  
3 use 5.008;
4 use strict;
5 use warnings;
6 use Exporter ();
7 use List::Util ();
8  
9 use vars qw{ $VERSION @ISA @EXPORT };
10 BEGIN {
11 $VERSION = '0.33';
12 @ISA = 'Exporter';
13 @EXPORT = qw{
14 SPHERE_X
15 SPHERE_Y
16 SPHERE_Z
17 SPHERE_R
18 BOX_X1
19 BOX_Y1
20 BOX_Z1
21 BOX_X2
22 BOX_Y2
23 BOX_Z2
24 };
25 }
26  
27 # We can mostly avoid these, but they do help document things
28 use constant +{
29 map { $EXPORT[$_] => $_ } ( 0 .. $#EXPORT )
30 };
31  
32  
33  
34  
35  
36 ######################################################################
37 # Constructors
38  
39 sub new {
40 my $class = shift;
41 return bless [ @_ ], $class;
42 }
43  
44 sub box {
45 shift->new(
46 ($_[3] + $_[0]) / 2,
47 ($_[4] + $_[1]) / 2,
48 ($_[4] + $_[2]) / 2,
49 List::Util::max(
50 $_[3] - $_[0],
51 $_[4] - $_[1],
52 $_[5] - $_[2],
53 ) / 2,
54 @_,
55 );
56 }
57  
58 sub sphere {
59 shift->new(
60 @_,
61 $_[0] - $_[3],
62 $_[1] - $_[3],
63 $_[2] - $_[3],
64 $_[0] + $_[3],
65 $_[1] + $_[3],
66 $_[2] + $_[3],
67 );
68 }
69  
70 1;