# Problem with RegionDisjoint and 3D-Polygons

Bug introduced in 12.1 or earlier and persisting in 13.0.0

I have a flat 3D-Polygon (all points have the same z-Value) and a 3D-line, which I need to check if they intercept using RegionDisjoint. Assume this:

line = {{-7, 100, 42}, {0, 15, 10}};
poly = {{-(49/10), 266/5, 43/2}, {-(89/10), 47, 43/2}, {-(54/5), 85/2,
43/2}, {-(62/5), 217/5, 43/2}, {-(88/5), 499/10, 43/
2}, {-(183/10), 487/10, 43/2}, {-(211/10), 221/5, 43/
2}, {-(17/10), 162/5, 43/2}, {69/10, 459/10, 43/2}, {-(22/5), 53,
43/2}};
RegionDisjoint[Line[line], Polygon[poly]]
Graphics3D[{Line[line], Polygon[poly]}]


This doesn't evaluate. It just returns this: When I simply remove one random point of the polygon or move it up above the end of the line (z-coordinate >43/2) it suddenly evaluates. This example:

poly2 = poly*2;
RegionDisjoint[Line[line], Polygon[poly2]]


returns True. What am I doing wrong here?

Mathematica 12.1 on Windows 11

• As a workaround, RegionIntersection[Line[line], Polygon[poly]] returns a point in your case, indicating that there is an intersection. Perhaps you could could use that return value as a stop gap measure. Jan 14 at 15:07
• Something is odd though: RegionDisjoint[Line[line], Polygon[poly], GenerateConditions -> True] returns an error: "RegionDisjoint::reg: GenerateConditions->True is not a correctly specified region.". That is unexpected! I wonder if something is going awry within RegionDisjoint then. Jan 14 at 15:13
• It also works for InfiniteLine, i.e., RegionDisjoint[ InfiniteLine[line], Polygon[poly]] evaluates to False Jan 14 at 16:03

It seems be a bug. By now we have to solve it manually.

poly = {{-(49/10), 266/5, 43/2}, {-(89/10), 47, 43/2}, {-(54/5), 85/2,
43/2}, {-(62/5), 217/5, 43/2}, {-(88/5), 499/10,
43/2}, {-(183/10), 487/10, 43/2}, {-(211/10), 221/5,
43/2}, {-(17/10), 162/5, 43/2}, {69/10, 459/10, 43/2}, {-(22/5),
53, 43/2}};
line = {{-7, 100, 42}, {0, 15, 10}};

Solve[{x, y, z} ∈ Polygon[poly] && {x, y, z} ∈
Line[line], {x, y, z}]

Reduce[{RegionMember[Polygon[poly]]@{x, y, z},
RegionMember[Line[line]]@{x, y, z}}, {x, y, z}]

FindInstance[{{x, y, z} ∈
Polygon[poly] , {x, y, z} ∈ Line[line]}, {x, y, z}]


{{x -> -(161/64), y -> 2915/64, z -> 43/2}}

Graphics3D[{Line[line], Polygon[poly], Red,
Ball[SolveValues[{x, y, z} ∈
Polygon[poly] && {x, y, z} ∈ Line[line], {x, y, z}]]}] We can define a regionDisjoint to do this.

regionDisjoint[reg1_, reg2_] :=
If[Reduce[{RegionMember[reg1]@{x, y, z},
RegionMember[reg2]@{x, y, z}}, {x, y, z}] === False,True,False];

regionDisjoint[Line[line], Polygon[poly]]

regionDisjoint[Line[line], Polygon[2poly]]


False

 True

or define

regiondisjoint =
If[RegionIntersection[#1, #2] === EmptyRegion, True, False] &
regiondisjoint[Line[line], Polygon[poly]]
regiondisjoint[Line[line], Polygon[2poly]]


False

True