title: Linear interpolation along a "Bresenham line"
body: <p>I'm using linear interpolation for animating an object between two 2d coordinates on the screen. This is pretty close to what I want, but because of rounding, I get a jagged motion. In ASCII art:</p>
  
  <pre><code>ooo
    ooo
      ooo
        oo
  </code></pre>
  
  <p>Notice how it walks in a Manhattan grid, instead of taking 45 degree turns. What I'd like is linear interpolation along the line which <a href="http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm" rel="noreferrer">Bresenham's algorithm</a> would have created:</p>
  
  <pre><code>oo
    oo
      oo
        oo
  </code></pre>
  
  <p>For each x there is only one corresponding y. (And swap x/y for a line that is steep)</p>
  
  <p>So why don't I just use Bresenham's algorithm? I certainly could, but that algorithm is iterative, and I'd like to know just one coordinate along the line.</p>
  
  <p>I am going to try solving this by linearly interpolating the x coordinate, round it to the pixel grid, and then finding the corresponding y. (Again, swap x/y for steep lines). No matter how that solution pans out, though, I'd be interested in other suggestion and maybe previous experience.</p>