1 2 3 4 5 6 7 8 9 10 11 12 13

// The boxtoline intersection test
bool LBIntersection(Vector p1, Vector p2, double x1, double y1, double x2, double y2)
{
Vector p3, p4, p5, p6;
p3.x = x1, p4.x = x2, p5.x = x2, p6.x = x1;
p3.y = y1, p4.y = y1, p5.y = y2, p6.y = y2;
// Check each side of the box
if(LLIntersection(p1, p2, p3, p4)) return true;
if(LLIntersection(p1, p2, p4, p5)) return true;
if(LLIntersection(p1, p2, p5, p6)) return true;
if(LLIntersection(p1, p2, p6, p3)) return true;
return false;
}
