Unexpected behavior of the procedure `Area` on the object 'Polygon'

EDIT: Reported to WRI as CASE:4237867 - fixed on V12. :)

Seems like a bug in my opinion. Consider the following:

With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]}, 
 With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
  {poly0 === poly, Area /@ {poly0, poly}}]]

{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}

Although the Mma considers poly0 and its transformed but identical copy (coordinates transformed using IdentityMatrix) identical, they produce different results.

Probably the internal representation of poly is not the same as poly0. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.

This can be further simplified to show that from the perspective of Polygon two semantically identical coordinate lists can differ:

With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
 With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
  {coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]

{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}

I suspect there's something wrong with the way Polygon reads the internal representation of a list!

EDIT: I think there's a good chance this problem is caused by the fact coord is a packed array, while coord0 is not:

With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
 With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
  {coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord}, 
   Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]

{True, {False, True}, {12, 12}}

So, you can use FromPackedArray on the transformed coordinate list as a workaround.


This is a packed array issue:

Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]

Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]

This will be fixed in M12.