title: 2D line intersection point with a bounding box
body: <p>What would be an efficient algorithm for calculating the intersection point of a line starting a (x,y), with an angle of θ, and a bounding rectangle with co-orindates (0,0 to w,h)?  Assuming the line origin is within the box.</p>
  
  <p>In basic ascii art (for a line starting at 2,6 and θ approx 9π/8):</p>
  
  <pre><code> h---------------...h,w
   .               ...
   .               ... 
   .               ...
   7               ...
   6   x           ...
   5  /            ...
   4 /             ...
   3/              ...
   2               ...
  /1               ...
   0 1 2 3 4 5 6 7 ... w
  </code></pre>
  
  <p>All variables, except θ, are integers.</p>