« lib/App/SeismicUnixGui/misc/SeismicUnix.pm
↑ Summary
lib/App/SeismicUnixGui/misc/check_buttons.pm »
| 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; |