I'm playing with a weather vane (aka a wind direction indicator). It returns a number from 0 to 359. I'd like to apply some damping/averaging to stabilize the displayed value.
Normally with this sort of issue I'd just load all the most recent readings into an array and take an average. The problem is that this doesn't work with circular values - consider 355 degrees and 5 degrees, mathematically they average 180 degrees, but from a direction perspective they should average 0 (north).
There's a weighty mathematical solution explained here.... https://en.wikipedia.org/wiki/Mean_of_circular_quantities
My question is this, do I need to bite the bullet and get down to some serious maths, or is there a quick and dirty fix to produce similar results?