I have two points a and b, and a bounding box at 0,0,w,h. Both points are within the bounding box. How do I extend the line segment created by a and b to find points c and d where the line intersects the box?
*c-------------*
| \ |
| \ |
| a |
| \ |
| \ |
| b |
| \ |
*--------d-----*
Get the equation for the line
For each (vertical) side take that X and solve for Y – check if Y is between the top and bottom.
If not then use the horizontal side’s Y values and solve for ‘X’