File Coverage

blib/lib/Math/Window2Viewport.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 3 3 100.0
total 25 25 100.0


line stmt bran cond sub pod time code
1             package Math::Window2Viewport;
2 2     2   79915 use strict;
  2         6  
  2         73  
3 2     2   12 use warnings FATAL => 'all';
  2         5  
  2         648  
4             our $VERSION = '1.00';
5              
6             sub new {
7 1     1 1 96 my $class = shift;
8 1         11 my $self = bless {@_}, $class;
9              
10 1         9 $self->{Sx} = ( $self->{Vr} - $self->{Vl} ) / ( $self->{Wr} - $self->{Wl} );
11 1         5 $self->{Sy} = ( $self->{Vt} - $self->{Vb} ) / ( $self->{Wt} - $self->{Wb} );
12 1         6 $self->{Tx} = ( $self->{Vl} * $self->{Wr} - $self->{Wl} * $self->{Vr} ) / ( $self->{Wr} - $self->{Wl} );
13 1         6 $self->{Ty} = ( $self->{Vb} * $self->{Wt} - $self->{Wb} * $self->{Vt} ) / ( $self->{Wt} - $self->{Wb} );
14            
15 1         5 return $self;
16             }
17              
18             sub Dx {
19 6     6 1 646 my ($self,$x) = @_;
20 6         50 return $self->{Sx} * $x + $self->{Tx};
21             }
22              
23             sub Dy {
24 6     6 1 15 my ($self,$y) = @_;
25 6         45 return $self->{Sy} * $y + $self->{Ty};
26             }
27              
28             1;
29              
30             __END__