title: Linear interpolation code on wikipedia - I don't understand it
body: <p>I'm reading the following code (taken from <a href="http://en.wikipedia.org/wiki/Linear_interpolation#C_Language_implementation_of_linear_interpolation" rel="nofollow noreferrer">here</a>)</p>
  
  <pre><code>void linear_interpolation_CPU(float2* result, float2* data, 
                                float* x_out, int M, int N) {     
      float a;
      for(int j = 0; j &lt; N; j++) {
          int k = floorf(x_out[j]);
          a = x_out[j] - floorf(x_out[j]);
          result[j].x = a*data[k+1].x + (-data[k].x*a + data[k].x);
          result[j].y = a*data[k+1].y + (-data[k].y*a + data[k].y);
      }   
  }
  </code></pre>
  
  <p>but I don't get it.</p>
  
  <p>Why isn't the result[y] calculated by using the</p>
  
  <p><img src="https://i.stack.imgur.com/bDbtZ.png" alt="enter image description here"></p>
  
  <p>formula?</p>