lib/App/SeismicUnixGui/misc/algebra_by.pm untested

filter: Statementstmt 0.0% 0 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 14 CC 1 SCAR 6.9
CC
1
Cov
0%
rotate2
2.0
CRAP 2.0
1 package App::SeismicUnixGui::misc::algebra_by;
2  
3 # perform matrix math on arrays by class
4 # Contains methods/subroutines/functions to operate on directories
5 # V 1. April 15 2008
6 # Juan M. Lorenzo
7  
8 sub rotate2 {
9  
10 # rotate an X,Y pair by rot radians. +ve CCW. -ve CW
11 # rotate a vector by rot radians. +ve CCW. -ve CW
12  
13 my ( $ref_X, $ref_Y, $num_elements, $rot ) = @_;
14  
15 #print("\nrotation value is: $rot \n");
16 #print("Number of row(s) is: $num_elements \n");
17  
18 my $cost = cos($rot);
19 my $sint = sin($rot);
20  
21 #print("\ncos value is: $cost \n");
22 #print("sin value is: $sint \n");
23 for ( $i = 1 ; $i <= $num_elements ; $i++ ) {
24  
25 $X[$i] = $$ref_X[$i] * $cost - $$ref_Y[$i] * $sint;
26 $Y[$i] = $$ref_X[$i] * $sint + $$ref_Y[$i] * $cost;
27  
28 }
29  
30 # make sure arrays do not contaminate outside
31 my @XX = @X;
32 my @YY = @Y;
33  
34 return ( \@XX, \@YY );
35  
36 }
37  
38 1;