Having some problems Generating random Polygons
and then filtering by Area
, specifically filter out degenerated polygons with undefined Area
is crashing the kernel in 12.0.
randomThirdPoints[n_] := Table[1/3 {RandomChoice[{0,1,2,3}],RandomChoice[{0,1,2,3}]},{n}]
Here are some random 4-gons in the unit square:
randomPolygons4 := Table[Polygon[randomThirdPoints[4]], 100];
This step is consistently crashing kernel:
randomPolygons4 // Map[Area]
similarly if using Select
, AssociationMap
and also using RegionQ
instead of Area
.
Are there some safer options? Ref Page doesn't seem to help.
Area
function crashes for some polygons. YouSeedRandom
when you experiment so that the problem appears consistently. For example, usingRandomSeed[1]
, you'll see thatrandomPolygons4[[39]] // Area
crashes the kernel. The polygon looks like this:Polygon[{{1/3, 1/3}, {0, 0}, {1/3, 1/3}, {0, 2/3}}]
This seems like a problem for WRI. $\endgroup$safePointSets = Table[randomThirdPoints[4], 100] // Select[DuplicateFreeQ]
and thensafePointSets // Map[Polygon] // Map[Area]
seems to work. $\endgroup$