RosettaCodeData/Task/Averages-Mean-angle/PowerShell/averages-mean-angle-1.psh

8 lines
307 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
function Get-MeanAngle ([double[]]$Angles)
{
$x = ($Angles | ForEach-Object {[Math]::Cos($_ * [Math]::PI / 180)} | Measure-Object -Average).Average
$y = ($Angles | ForEach-Object {[Math]::Sin($_ * [Math]::PI / 180)} | Measure-Object -Average).Average
[Math]::Atan2($y, $x) * 180 / [Math]::PI
}