I have a long list of numbers that contains measured angles. The basic idea is that it looks something like this:
var list = new List<double>() {352.9, 354.9, 356.9, 359, 1, 3.1, 5.9};
I am looking for a way to obtain the nearest upper and lower value when I specify some value x. So for example if x = 354.6, I want the upper value to be x_up = 354.9 and the lower value to be x_low = 352.9. I though about using this method, but it does not taking into account that circle angles follow a modulo system.
When x = 0.2, I want x_up = 1 and x_low = 359.
Any ideas on how I can implement this?