# Bugs with computational geometry: versions 12.2 vs 13.2

### Updated

System Info: HONOR laptop AMD Ryzen 5 4600H 3Hz 6 cores 16GB Memory,
Windows 10 Pro 64 bit with updates.

Mathematica Info: Versions 12.2 and 13.2, both on the same laptop.

Examples:

p1 = RandomPolygon[{"Simple", 50}, DataRange -> {{1, 2}, {1, 2}}];
p2 = RandomPolygon[{"Simple", 50}, DataRange -> {{1, 2}, {1, 2}}];

Timing[RegionIntersection[p1, p2] === EmptyRegion[2]]


WM 12.2: 0.1-0.3 s vs WM 13.2: 3.1-3.6 s

Timing[RegionDifference[p1, p2]]


WM 12.2: 0.3-0.34 s vs WM 13.2: 3.4-3.5 s

Timing[RegionUnion[p1, p2]]


WM 12.2: 0.1-0.2 s vs WM 13.2: 0.7-0.9 s

Other operations (graphs, big numbers) do not show such differences, but I still checking.

### More specific question

For one demo, I'd like to create shapes like this one:

Not too complex (without holes and self-intersections), so the output is just simple polygon with 30-50 vertices:

bf[p_, s_] :=
BSplineFunction[p, SplineClosed -> True, SplineDegree -> s];
initialShape =
With[{pts = RandomReal[{0.2, 0.6}, {9, 2}]*CirclePoints[9]},
Polygon[Table[ bf[pts, 4][t], {t, 0, 1, 0.02}]]
];
shape[center_, size_] :=
TranslationTransform[center][
ScalingTransform[{size, size}][initialShape]];


For further I need to analyze the intersections of these figures. The problem with RegionDisjoint has already been described here, and in version 13.2 it still remained:

RegionDisjoint[shape[{1., 1.}, 1.], shape[{5., 5.}, 2.]]


Output:

OK, we can use RegionIntersection:

isNonIntersect[shape1_, shape2_] :=
RegionIntersection[shape1, shape2] === EmptyRegion[2];


It works, but I found big oddities with the timing of RegionIntersection:

Result:
True Version 12.2: 0.06-0.08s Version 13.2: 1.2-1.3s
False Version 12.2: 0.0s Version 13.2: 0.01-0.2s

Why does it take longer to get True, and why Mathematica 13.2 is so slow?!
(all it runs on the same laptop with Win 10)

• I have no answer to this but I'd suggest applying BoundaryDiscretizeRegion or DiscretizeRegion to the polygon; as far as I know it should result equivalent region, at least for polygons with machine-precision coordinate values. Also, mesh regions tend to behave better on intersections etc. than polygons. Commented Jan 20, 2023 at 7:26
• Can you provide an example of a specific pair of non-overlapping regions which show this performance difference? That is, a SeedRandom value and shape specifications. Commented Jan 20, 2023 at 7:59
• @kirma Yes, soon, I'm preparing a separate question about the performance of version 13.2, it is slower than 12.2 in almost everything Commented Jan 20, 2023 at 8:23
• Please see How to report a bug in Mathematica. Making a post here is a great way to get a workaround for something, or confirmation that others can reproduce. But if bugs are to be fixed they need to be reported to Wolfram directly. Commented Jan 20, 2023 at 16:58
• @kirma You was almost right thanks! Just not DiscretizeRegion but BoundaryMeshRegion works very well Commented Jan 21, 2023 at 7:28

myRegion[pts_] :=

It's 10-15 times faster than UnsameQ[RegionIntersection[Polygon@verts1, Polygon@verts2], EmptyRegion[2]] both on 12.2 and 13.2.