3
$\begingroup$

Suppose I have two overlapping regions $R1$ and $R2$ looking like this:

RegionPlot[{(250 x01 - 433 x02 <= 0 && 
250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 && 
433 x01 + 250 x02 <= 2000/3 && 
433 x01 + 250 x02 >= 0), (683 x01 - 183 x02 <= 2000/3 && 
683 x01 - 183 x02 >= 0 && 1116 x01 + 67 x02 >= 800/3 && 
433 x01 + 250 x02 <= 2000/3 && 
433 x01 + 250 x02 >= 0)}, {x01, -0.5, 1.5}, {x02, -2, 2}]

enter image description here

Now suppose I would like to plot the intersection of those two regions $R1 \land R2 $ as a separate region, together with original regions minus their intersection - i.e. I want to plot the regions $R1 \land R2$, $R1 \land \lnot (R1 \land R2)$, $R2 \land \lnot (R1 \land R2)$ - this can obviously be done via the following command

RegionPlot[{(250 x01 - 433 x02 <= 0 && 
 250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 && 
 433 x01 + 250 x02 <= 2000/3 && 
 433 x01 + 250 x02 >= 0) && (683 x01 - 183 x02 <= 2000/3 && 
 683 x01 - 183 x02 >= 0 && 1116 x01 + 67 x02 >= 800/3 && 
 433 x01 + 250 x02 <= 2000/3 && 
 433 x01 + 250 x02 >= 0), (250 x01 - 433 x02 <= 0 && 
 250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 && 
 433 x01 + 250 x02 <= 2000/3 && 
 433 x01 + 250 x02 >= 
  0) && ! ((250 x01 - 433 x02 <= 0 && 
    250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 &&
     433 x01 + 250 x02 <= 2000/3 && 
    433 x01 + 250 x02 >= 0) && (683 x01 - 183 x02 <= 2000/3 && 
    683 x01 - 183 x02 >= 0 && 1116 x01 + 67 x02 >= 800/3 && 
    433 x01 + 250 x02 <= 2000/3 && 
    433 x01 + 250 x02 >= 0)), (683 x01 - 183 x02 <= 2000/3 && 
 683 x01 - 183 x02 >= 0 && 1116 x01 + 67 x02 >= 800/3 && 
 433 x01 + 250 x02 <= 2000/3 && 
 433 x01 + 250 x02 >= 
  0) && ! ((250 x01 - 433 x02 <= 0 && 
    250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 &&
     433 x01 + 250 x02 <= 2000/3 && 
    433 x01 + 250 x02 >= 0) && (683 x01 - 183 x02 <= 2000/3 && 
    683 x01 - 183 x02 >= 0 && 1116 x01 + 67 x02 >= 800/3 && 
    433 x01 + 250 x02 <= 2000/3 && 
    433 x01 + 250 x02 >= 0))}, {x01, -0.5, 1.5}, {x02, -2, 2}]

which results in the output

enter image description here

My question is - how could I do this for more complicated situations with more than two overlapping regions, as for example, for this set of regions:

RegionPlot[{(250 x01 - 433 x02 <= 0 && 
250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 && 
433 x01 + 250 x02 <= 2000/3 && 
433 x01 + 250 x02 >= 0), (683 x01 - 183 x02 <= 2000/3 && 
683 x01 - 183 x02 >= 0 && 1116 x01 + 67 x02 >= 800/3 && 
433 x01 + 250 x02 <= 2000/3 && 
433 x01 + 250 x02 >= 0), (250 x01 - 433 x02 <= 0 && 
250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 <= 0 && 
683 x01 - 183 x02 >= -(2000/3) && 
433 x01 + 250 x02 >= 800/3), (250 x01 - 433 x02 <= 2000/3 && 
250 x01 - 433 x02 >= 0 && 683 x01 - 183 x02 <= 2000/3 && 
683 x01 - 183 x02 >= 0 && 
433 x01 + 250 x02 >= -400), (250 x01 - 433 x02 <= 2000/3 && 
250 x01 - 433 x02 >= 0 && 683 x01 - 183 x02 >= 800/3 && 
433 x01 + 250 x02 <= 0 && 
433 x01 + 250 x02 >= -(2000/3)), (683 x01 - 183 x02 <= 0 && 
683 x01 - 183 x02 >= -(2000/3) && 1116 x01 + 67 x02 >= -400 && 
433 x01 + 250 x02 <= 0 && 
433 x01 + 250 x02 >= -(2000/3)), (683 x01 - 183 x02 <= 800/3 && 
683 x01 - 183 x02 >= -400 && 1116 x01 + 67 x02 <= 800/3 && 
1116 x01 + 67 x02 >= -400 && 433 x01 + 250 x02 <= 800/3 && 
433 x01 + 250 x02 >= -400), (933 x01 - 616 x02 <= 1000 && 
933 x01 - 616 x02 >= -1000 && 1116 x01 + 67 x02 <= 1000 && 
1116 x01 + 67 x02 >= -100 && 183 x01 + 683 x02 <= 1000 && 
183 x01 + 683 x02 >= -1000)}, {x01, -0.5, 1.5}, {x02, -2, 2}]

Hence, what I want is a set of disjoint regions, each of which is some intersection of the original regions.

$\endgroup$
0
$\begingroup$

You should be able to use geometric computation tools (RegionUnion, RegionIntersection, RegionDifference) to do so implicitly.

Here is what I mean on the smaller example you provided. Let's first create your two regions from the simpler example as ImplicitRegion objects and name them for convenience:

{region1, region2} = 
 ImplicitRegion[#, {x01, x02}] & /@ {250 x01 - 433 x02 <= 0 && 
    250 x01 - 433 x02 >= -(2000/3) && 683 x01 - 183 x02 >= -400 && 
    433 x01 + 250 x02 <= 2000/3 && 433 x01 + 250 x02 >= 0, 
   683 x01 - 183 x02 <= 2000/3 && 683 x01 - 183 x02 >= 0 && 
    1116 x01 + 67 x02 >= 800/3 && 433 x01 + 250 x02 <= 2000/3 && 
    433 x01 + 250 x02 >= 0};

We can then show 1. the intersection between the two; 2. and 3. the difference between the union of the two regions and each of them:

RegionPlot[Evaluate@Flatten@
   {
    (* The intersection between the two regions *)
    RegionIntersection[region1, region2],
    (* The two differences, calculated as the union - each region *)
    RegionDifference[RegionUnion[region1, region2], #] & /@ {region1, region2}
   }
]

Mathematica graphics

$\endgroup$

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.