Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use feature 'say';
- use Math::Trig;
- my $file = 'datatest.dat';
- open my $in, '<', $file or die "File Not Found\n";
- my @aa = ();
- my @bb = ();
- my @cc = ();
- my @dd = ();
- my $i = 0;
- while(<$in>){
- my @data = split;
- my $ra = deg2rad $data[0]; #radに変換
- my $dec = deg2rad $data[1];
- $aa[$i] = cos $dec;
- $bb[$i] = sin $ra;
- $cc[$i] = cos $ra;
- $dd[$i] = sin $dec;
- $i++;
- }
- close($in);
- my $size = scalar @aa;
- for ($i = 0; $i < $size; $i++) {
- for (my $j = $i + 1; $j < $size; $j++) {
- my $theta = rad2deg(
- sqrt(
- ($aa[$i] * $bb[$i] - $aa[$j] * $bb[$j]) ** 2 +
- ($aa[$i] * $cc[$i] - $aa[$j] * $cc[$j]) ** 2 +
- ($dd[$i] - $dd[$j]) ** 2
- )
- );
- say $theta;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement