I have a list of 2 Polygon
objects (see below for the list polys
and a visualization). They are all seem valid. Still, when I try to map Area
over this list (after a fresh kernel restart), it crashes the kernel. Surprisingly, when mapping over the reversed list (after a fresh kernel restart) it works. For each individual Polygon
in the list, Area
works as expected.
This bug has kept me busy for a full day already, finally pinpointing it to this MWE.
- What is going on here?
- How can this be avoided?
- What is a 'safe' order of the polygons in a list, in order to map
Area
over it?
My setup: Macbook Pro, 32 GB RAM, macOS 10.14.6, Mathematica 13.0.
What doesn't work for me (after a fresh kernel start; though, doing this after trying what does work, it also works; maybe a caching issue?):
Map[Area, polys]
The above call silently crashes my kernel (no error message whatsoever).
The following do work (try each after restarting the kernel, e.g. using Quit[]
):
Area@polys[[1]]
Area@polys[[2]]
Map[Area, Reverse@polys]
N.B. Polygon 1 has two (almost) collinear edges. In other cases this has never been an issue. Besides, the evaluation of the individual areas is not the issue. The crash is triggered by the order of evaluation.
A visualization of the 2 polygons (they come from a much longer list):
Here is the list of polygons:
polys = {Polygon[{{-12., 20.784609690826528`}, {-16.,
13.856406460551018`}, {0., 0.}, {-6., 10.392304845413264`}}],
Polygon[{{48., 20.784609690826528`}, {42., 31.17691453623979}, {
36., 20.784609690826528`}}]};
{62.3538, 83.1384}
{83.1384, 62.3538}
$\endgroup$Map[Area, Reverse@polys]
first thenMap[Area, polys]
works fine. However, evaluatingMap[Area, Reverse@polys]
afterMap[Area, polys]
(even ifMap[Area, Reverse@polys]
has already been successfully evaluated) crashes the kernel. Oddly,Area /@ (polys = RandomPolygon[3, 10])
andArea /@ Reverse[polys]
work irrespective of order. Recommend that you report this to Wolfram Tech Support. $\endgroup$