I don't understand the problem the OP is having. Basically my understanding is from a group of three degree values, take the middle one and replace it with the average of the two outer ones. The math is easy, and if the resulting value < 360 just add 360 to it. However, this math does not take into account the original value of the middle number. So, with an array like:
10, 80, 20, 95, 30, 160, 40
you would get an array of:
10, 15, 55, 42.5, 101.25, 70.625, 40
(assuming the end value of 40 does not change, like the first value does not change).
I have no idea what this is supposed to be for, but I think it is not the proper solution based on the fact that the OP says the numbers can come in any order, etc.
|