I have been thinking about this average wind direction and it is actually pretty tricky to implement! The periodic nature of wind direction 0-359 degrees with a “reset” to 0 degrees is the kicker. Taking an average is more complicated than I thought!
Assume we have this reduced data set to make an average: 355, 355, 5, 5
If you add them up and divide by 4 you get 180, which is exactly the opposite of the true wind direction average of 0 degrees. I’m sure there’s an algorithm that can fix this but it isn’t as straightforward as I originally thought, at first glance.
It probably would do something like figure out the general span of wind direction in a 180 or 270 degree range, that re-maps the raw numbers to greater than 359, so 5 degrees might become 365 degrees for the calculation, then the simple averaging method would work… i.e.
355, 355, 365, 365 added together and divided by 4 yields 360 = 0 degrees
just wondering where these two lines are good for, atan2(y,x) is almost the same as atan(y/x) so multiplying both with the same number is kind of pointless. isn’t it?
It doesn’t matter too much, I was just curious about how you calculated it. But those two lines are redundant. Atan((ya) /(xa)) is independent of the value of a ( unless a is zero). atan2 is just a fancy, better way of calculating this.