Chris BHR - I do some averaging of various para...

I do some averaging of various parameters within node-red to smooth them out but have the issue where this all gets ruined around 359 -> 0 degrees for obvious reasons. For the time being i've just shifted the issue around 180 degrees but does anyone have a neat function to properly account for this?
3 Replies
Teppo Kurki
Teppo Kurki4d ago
I am pretty sure somebody shared a flow to do this as vector average, but my search fu is lacking
Teppo Kurki
Teppo Kurki4d ago
Circular mean
In mathematics and statistics, a circular mean or angular mean is a mean designed for angles and similar cyclic quantities, such as times of day, and fractional parts of real numbers. This is necessary since most of the usual means may not be appropriate on angle-like quantities. For example, the arithmetic mean of 0° and 360° is 180°, which ...
Chris BHR
Chris BHROP3d ago
That's it! It seems so simple now. Take the sin of the angle, do the averaging and then take the inverse sine of the result! Thank you! Turns out it wasnt quite as simple as i thought above but not far off. You have to take sin and cos of the angle, do your averaging on each of those and then use Math.atan2(averagesin,averagecos). Just in case this is of any use to anyone else!

Did you find this page helpful?