<p>I have two points (a line segment) and a rectangle. I would like to know how to calculate if the line segment intersects the rectangle. </p>

Do
http://mathworld.wolfram.com/Line-LineIntersection.html
for the line and each side of the rectangle.
Or:
http://mathworld.wolfram.com/Line-PlaneIntersection.html