2
$\begingroup$

I am having trouble computing the area of the following polygon. I have the following polygon:

polygon = Polygon[{{0, 0}, {0, 1}, {2/10, 1}, {2/10, 8/10}, {4/10, 8/10}, {4/10, 6/10}, {1, 0}}]

The command

Region[polygon]

plots it just fine. I cannot hower compute its area using

RegionMeasure[polygon]

I get the following error

RegionMeasure::nmet: Unable to compute the measure of region Polygon[{{0,0},{0,1},{1/5,1},{1/5,4/5},{2/5,4/5},{2/5,3/5},{1,0}}]

It is not clear to me what causes this error.

EDIT: I need an exact result.

$\endgroup$
7
  • 1
    $\begingroup$ Hm. Runs without problems in version 12.0 for macos... But earlier versions of Mathematica (like 10.x and 11.x) might have had problems with Region-related functions... $\endgroup$ Nov 25, 2019 at 16:22
  • $\begingroup$ Runs without problems in MMA version 12.0 for Windows 10 Home 64 bit. $\endgroup$ Nov 25, 2019 at 16:41
  • $\begingroup$ I don't have an older version of MMA to try it with, but you might be able to try Area[Region[polygon]] or RegionMeasure[Region[polygon]]. $\endgroup$
    – MassDefect
    Nov 25, 2019 at 18:13
  • 1
    $\begingroup$ You can always use the shoelace method for computing the area, of course. $\endgroup$ Nov 26, 2019 at 6:03
  • $\begingroup$ Thanks, indeed my version 12.0 works. Unfortunately, my server runs 11.3 which would be great to use to speed up the computation. Both Area[Region[polygon]] and RegionMeasure[Region[polygon]] do not seem to work for me. $\endgroup$ Nov 26, 2019 at 8:45

1 Answer 1

2
$\begingroup$

If we first use DiscretizeRegion, then it's no problem on version 10.1.

RegionMeasure@DiscretizeRegion@polygon

0.54

$\endgroup$
1
  • $\begingroup$ As far as I understand the DiscretizeRegion method I cannot be sure that it gives me an exact results, although it is the case here(represented as float). Unfortunately I need an exact results. $\endgroup$ Nov 26, 2019 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.