I have been trying to find the intersections between a rectangle and a line, following the example given in the Solve function:
Solve[{x, y} ∈ Line[{{-1, 0}, {2, 1}}] && {x, y} ∈
Circle[], {x, y}]
Graphics[{{Blue, Line[{{-1, 0}, {2, 1}}],
Circle[]}, {PointSize[Large], Red, Point[{x, y}] /. %}}]
this code works well of course, finding both intersections between the circle and the line. However, if I try to substitute the circle with a rectangle the code stops working:
lin := Line[{{-2, -3}, {2, 1}}]
rec := Rectangle[{-1, -1}, {1, 1}]
Solve[{x, y} ∈ lin && {x, y} ∈ rec, {x, y}]
Graphics[{{Red, lin, Blue, rec}, {PointSize[Large], Yellow,
Point[{x, y}] /. %}}]
Any idea of how to make it work?
Thanks in advance