1
$\begingroup$

I have a region plot, and I would like to calculate the area:

With[{b = 2, h = 2}, RegionPlot[
{(x)^2 + (y - b)^2 > h^2 + b^2 &&
(x)^2 + (y - b - h)^2 > h^2 + b^2 &&
(x - h)^2 + (y - 2 b - h)^2 > h^2 + b^2 &&
(x - h - b)^2 + (y - 2 b - h)^2 > h^2 + b^2 &&
(x - 2 h - b)^2 + (y - b - h)^2 > h^2 + b^2 &&
(x - 2 h - b)^2 + (y - b)^2 > h^2 + b^2 &&
(x - h - b)^2 + (y)^2 > h^2 + b^2 &&
(x - h)^2 + (y)^2 > h^2 + b^2}, {x, 0, 2 h + b}, {y, 0, 2 b + h}]]

I have tried defining it as an ImplicitRegion but Area evaluates to Infinity. I am sure I am doing something wrong that is very simple, but I can't see what.

$\endgroup$
  • 1
    $\begingroup$ Well, if you can extract the polygons, there's this. $\endgroup$ – J. M.'s technical difficulties Jun 30 '15 at 3:16
  • 2
    $\begingroup$ For approximate area: Area @ DiscretizeGraphics @ g. Where g is your graphics. $\endgroup$ – RunnyKine Jun 30 '15 at 5:10
4
$\begingroup$

ImplicitRegion seems to work fine:

ir = With[{b = 2, h = 2}, 
 ImplicitRegion[{(x)^2 + (y - b)^2 > 
   h^2 + b^2 && (x)^2 + (y - b - h)^2 > 
   h^2 + b^2 && (x - h)^2 + (y - 2 b - h)^2 > 
   h^2 + b^2 && (x - h - b)^2 + (y - 2 b - h)^2 > 
   h^2 + b^2 && (x - 2 h - b)^2 + (y - b - h)^2 > 
   h^2 + b^2 && (x - 2 h - b)^2 + (y - b)^2 > 
   h^2 + b^2 && (x - h - b)^2 + (y)^2 > 
   h^2 + b^2 && (x - h)^2 + (y)^2 > h^2 + b^2}, 
   {{x, 0, 2 h + b}, {y, 0, 2 b + h}}]];

FullSimplify[Area[ir]]

(* (8 Pi)/3 - 4 (-7 + 2 Sqrt[3] + Sqrt[7] + 4 ArcCos[3/4]) *)

which agrees with the approximate area based on the plot per RunnyKine's comment

Area[DiscretizeGraphics[RegionPlot[ir]]]

(* 0.375737 *)

or the approximate area based on the discretized region

Area[DiscretizeRegion[ir]]

(* 0.374631 *)

The last value can be made more accurate by using a finer mesh.

Area[DiscretizeRegion[ir, PrecisionGoal -> 9]]

(* 0.374421 *)
| improve this answer | |
$\endgroup$
  • $\begingroup$ ah - thank you! I was using {x,y} at the end insterad of {{x, 0, 2 h + b}, {y, 0, 2 b + h}} - I didn't realise you needed the extra curly brackets around it & wondered why {x, 0, 2 h + b}, {y, 0, 2 b + h} didn't work!! $\endgroup$ – martin Jun 30 '15 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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