Two examples, one in Objective-C and one in Ruby, that demonstrate how to calculate the point of intersection between a line and a bounding box, if two points within the bounding box are known.
For more details, read my blog post about it: http://factore.ca/on-the-floor/166-how-to-calculate-the-point-of-intersection-between-a-line-and-a-bounding-box