Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Averages-Mean-angle/Perl/averages-mean-angle.pl
Normal file
17
Task/Averages-Mean-angle/Perl/averages-mean-angle.pl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
sub Pi () { 3.1415926535897932384626433832795028842 }
|
||||
|
||||
sub meanangle {
|
||||
my($x, $y) = (0,0);
|
||||
($x,$y) = ($x + sin($_), $y + cos($_)) for @_;
|
||||
my $atan = atan2($x,$y);
|
||||
$atan += 2*Pi while $atan < 0; # Ghetto fmod
|
||||
$atan -= 2*Pi while $atan > 2*Pi;
|
||||
$atan;
|
||||
}
|
||||
|
||||
sub meandegrees {
|
||||
meanangle( map { $_ * Pi/180 } @_ ) * 180/Pi;
|
||||
}
|
||||
|
||||
print "The mean angle of [@$_] is: ", meandegrees(@$_), " degrees\n"
|
||||
for ([350,10], [90,180,270,360], [10,20,30]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue