What's appen with my analog pin

I finally do as the following.

I created an array


int WDdirection10[18] {
  // analgo, direction (the wind come from)
  0,    0,    // N
  270,  45,  // NE
  561,  90,  // E
  642,  135,  // ES
  743,  180,  // S
  814,  225,  // SW
  870,  270,  // W
  920,  315,  // WN
  987, 360, // N
};

I use the following to know the direction the wind is coming from

  if (analogInput <= WDdirection10[0]) {     // Minimum value
    windDirection = WDdirection10[0 + 1];
  }
  if (analogInput >= WDdirection10[18]) {     // Maximum value
    windDirection = WDdirection10[18 + 1];
  }
  for (int i = 0; i < 18; i = i + 2) {
    if ((analogInput >= WDdirection10[i]) && (analogInput <= WDdirection10[i + 2]))
    {
      windDirection = WDdirection10[i + 1] - ((WDdirection10[i + 1] - WDdirection10[i + 3]) * ((analogInput - WDdirection10[i]) / (WDdirection10[i + 2] - WDdirection10[i])));
      Serial.print("\t"); Serial.println(windDirection);
      break;
    }
  }

It works fine. But as I have not write this code, is there some think I do not understand.

IF we consider, the van return 280, the following

windDirection = WDdirection10[i + 1] - ((WDdirection10[i + 1] - WDdirection10[i + 3]) * ((analogInput - WDdirection10[i]) / (WDdirection10[i + 2] - WDdirection10[i])));

will be egal to
45 - ((45 - 90) * ((280 - 270) / (561 - 270)));
my calculatir display the result of -1.546

but this


Serial.print("\t"); Serial.println(windDirection);

print 45

If I move my vane,, it print 45,90,135,180, etc

I do not rememer what does

windDirection = WDdirection10[i + 1] - ((WDdirection10[i + 1] - WDdirection10[i + 3]) * ((analogInput - WDdirection10[i]) / (WDdirection10[i + 2] - WDdirection10[i])));

I though, it was used to adjust the direction between 45 and 90, for exempe 55, if the vane is just after 270