2
$\begingroup$

Would you please explain to me a way that I can divide a polygon by means of a special line "represents the zero axis" into two regions so that I can determine each region individually. The question of : How to check if a line segment intersects with a polygon? is a nice example, however, I couldn't find a correct way to separate both upper and lower sub-polygons individually, and hence I can find the Area for each of them.

enter image description here

The data input are same for the mentioned question:

list = {{4.4, 14}, {6.7, 15.25}, {6.9, 12.8}, {9.5, 14.9}, {13.2, 
11.9}, {10.3, 12.3}, {6.8, 9.5}, {13.3, 7.7}, {0.6, 1.1}, {1.3, 
2.4}, {2.45, 4.7}};
Graphics[{Red, Line[{{0, 10}, {20, 0}}], Black, Polygon[list]}]
$\endgroup$
  • 2
    $\begingroup$ I have not tested this, but have you tried HalfPlane and RegionIntersection (potentially followed by another discretization step)? $\endgroup$ – Szabolcs Apr 25 '17 at 7:49
  • $\begingroup$ @Kuba The inputs and outputs are same for this example:mathematica.stackexchange.com/questions/66152/… $\endgroup$ – Mehmet Apr 25 '17 at 8:03
  • $\begingroup$ @Szabolcs, I tried to use the mentioned commands but RegionIntersection probably needs same number of Points? $\endgroup$ – Mehmet Apr 25 '17 at 8:06
  • 4
    $\begingroup$ I am not sure what you mean by "needs same number of Points", but what have you tried exactly? It works for me. Did you look up HalfPlane and RegionIntersection in the documentation? $\endgroup$ – Szabolcs Apr 25 '17 at 9:07
7
$\begingroup$

Following Szabolcs' suggestion,

Graphics[{Red, HalfPlane[{{0, 10}, {20, 0}}, {0, 1}], Black, Polygon[list]}]

graphics

Then direct applying RegionIntersection gives what you need:

Graphics[{RegionIntersection[HalfPlane[{{0, 10}, {20, 0}}, {0, 1}], Polygon[list]]}]

output

$\endgroup$
3
$\begingroup$

In:

xss = {{4.4, 14}, {6.7, 15.25}, {6.9, 12.8}, {9.5, 14.9}, {13.2, 
    11.9}, {10.3, 12.3}, {6.8, 9.5}, {13.3, 7.7}, {0.6, 1.1}, {1.3, 
    2.4}, {2.45, 4.7}};
halfPlane[y_] := HalfPlane[{{0, 10}, {20, 0}}, {0, y}];
halfRegion[reg1_, reg2_] := 
 DiscretizeRegion[RegionIntersection[reg1, reg2], AspectRatio -> 1]
halfRegion[Polygon[xss], halfPlane[#]] & /@ {-1, 1}

Out: enter image description here

$\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.