# RegionIntersection: Point or Line?

This may be a minor point, but I'm wondering why RegionIntersectionof the two rectangles below gives 3 Lines rather than 2 Lines and 1 Point.

rect1 = {AbsoluteThickness, Red, r1 = Line[{{0, 2}, {2, 2}, {2, 0}, {0, 0}, {0, 2}}]};
rect2 = {AbsoluteThickness, Blue, r2 = Line[{{0, 1}, {3, 1}, {3, 0}, {0, 0}, {0, 1}}]};
Graphics[{rect1, rect2}, Frame -> True]


AbsoluteThickness was used to show clearly where rect2 (blue) intersects with rect1 (red). Now let's display, in purple, the intersection of regions r1, r2.

intersection = RegionIntersection[r1, r2]
Graphics[{rect1, rect2, Purple, AbsoluteThickness, intersection},
Frame -> True, AspectRatio -> 1/GoldenRatio]


Note that one of the lines, Line[{{2, 1}}], is really a point. It plots it correctly, as a (very large) point. But why didn't RegionIntersection identify it as Point[{2, 1}]?

Line[{{{2, 1}}, {{0, 0}, {0, 1}}, {{0, 0}, {2, 0}}}] If line segments of the rectangles do not overlap, RegionIntersection returns Points, as expected. (By the way, I had to add AbsolutePointSize here because AbsoluteThickness affects Lines but not Points. The "point" plotted above was actually a line of length 0.)

rect3 = {AbsoluteThickness, Green, r3 = Line[{{-4, 9}, {4, 9}, {4, 3}, {-4, 3}, {-4, 9}}]};
rect4 = {AbsoluteThickness, Gray, r4 = Line[{{2, 10}, {14, 10}, {14, 4}, {2, 4}, {2, 10}}]};
intersection = RegionIntersection[r3, r4]
Graphics[{rect3, rect4, Purple, AbsolutePointSize, intersection}, Frame -> True, AspectRatio -> 1/GoldenRatio]


Point[{{2, 9}, {4, 4}}] • interesting, notice if the intersection is only discrete points then RegionIntersection does return a Point list. – george2079 Mar 28 '16 at 18:04
• Yes, I've used RegionIntersection in many other cases in which it returns a combination of Points and Lines – DavidC Mar 28 '16 at 18:16
• Looks like a bug to me, you may want to send this to support@wolfram.com – user21 Mar 29 '16 at 1:32
• I can't see this as a bug. The result is correct, both mathematically (a zero-length line is a point) and graphically (it displays as a point). For as long I can remember, Mathematica has always treated Line[{{{0, 1}}] and Line[{{0, 1}}, {{0, 1}}}] as the same thing. – m_goldberg Mar 29 '16 at 2:00
• Technically, I suppose, a line with no length may be equivalent to a point. However, I would expect Mathematica to return it in its standard form. In the particular case I am working on, I am trying to count the number of times a line crosses another line. Of course there is a workaround, but it is a bit clumsy. – DavidC Mar 29 '16 at 2:54

Querying the documentation I believe the answer to this question is because of this property of the function called RegionEmbeddingDimension:  In the first case:

rect1={AbsoluteThickness,Red,
r1=Line[{{0,2},{2,2},{2,0},{0,0},{0,2}}]};
rect2={AbsoluteThickness,Blue,
r2=Line[{{0,1},{3,1},{3,0},{0,0},{0,1}}]};
intersection1=RegionIntersection[r1,r2]
Graphics[{rect1,rect2,Purple,AbsoluteThickness,intersection1},
Frame->True,AspectRatio->1/GoldenRatio] Head[intersection1]


Line

It is the embedding dimension that gives the dimension of space. As the line was the largest dimension, it prevailed

In the second case:

rect3={AbsoluteThickness,Green,
r3=Line[{{-4,9},{4,9},{4,3},{-4,3},{-4,9}}]};
rect4={AbsoluteThickness,Gray,
r4=Line[{{2,10},{14,10},{14,4},{2,4},{2,10}}]};
intersection2=RegionIntersection[r3,r4]
Graphics[{rect3,rect4,Purple,AbsolutePointSize,intersection2},
Frame->True,AspectRatio->1/GoldenRatio] Head[intersection2]


Point

It is the embedding dimension that gives the dimension of space. As the point was the only dimension, it prevailed