0
$\begingroup$

I'm trying to numerically compute where an infinite line defined by two points intersects a (finite) rectangle also defined by two points. Here's a illustration of the various ways that the line can intersect the rectangle: A diagram showing "No intersections", "One intersection", "Two intersections", and "∞ intersections" How can I determine the number and location of the places where the infinite line intersects the rectangle? I know how to do this when the line is finite, but I can't figure out how to generalize that to an infinite context.

$\endgroup$
2
$\begingroup$

Idea: find out on which side of the line the four corners lie

  • no corners on the line and
    • all four corners on one side: $0$ intersections
    • one corner on one side, three corners on the other side: $2$ intersections
    • two corners on one side, two on the other side: $2$ intersections
  • exactly one corner on the line and
    • three on one side: $1$ intersection
    • one on one side, two on the other sides: $2$ intersections
  • exactly two corners on the line and
    • they are diagonally opposite ones: $2$ intersections
    • they are adjacent ones: infinitely many intersections
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.