# RegionIntersection fails for some values with polygons

Posted 8 years ago
4761 Views
|
2 Replies
|
0 Total Likes
|
 I want to find the intersection (region) of 2 polygons. I use RegionInstersection but it only works for some sizes, for example, when c=.5 it gives the correct result, but with c=.4 it only finds a line as intersection.Area[r3[.5]] works fine...Area[r3[.4]] does not work...What is wrong?b = 15.0; d = 4.0; lbp = 40.0; d1E = 2.; l1E = 7.0; d1D = d1E; l1D = 5.0;r1 = Polygon[{{0, 0}, {lbp/2 - l1D, 0}, {lbp/2, d1D}, {lbp/2, d}, {-(lbp/2), d}, {-(lbp/2), d1E}, {-(lbp/2) + l1E, 0}}]; r2[c_] := Rectangle[{-1.1 lbp/2, -1.5}, {1.1 lbp/2, c}]; r3[c_] := RegionIntersection[r1, r2[c]];
2 Replies
Sort By:
Posted 8 years ago
 There is indeed a problem (or bug?) here: Take the manipulate: Manipulate[ Column[{RegionMeasure[r3[c]], Graphics[{EdgeForm[Black], FaceForm[Gray], r1, EdgeForm[Red], FaceForm[], r2[c]}, Axes -> True, PlotRange -> {{-25, 25}, {-2, 7}}, ImageSize -> Medium]}], {{c, 2.5}, -.50, 6}] If you move the c slider toward c <=2, one start getting the error RegionMeasure::reg: r3[1.38] is not a correctly specified region. >> or worse, the kernel quit (exited) with the "why the beep?" message: "The kernel Local has quit (exited) during the course of this evaluation". And you lose all previous function definitions...However, I succeeded in making the plot: ListLinePlot@Table[{c, Area[r3[c]]}, {c, 0, 4, .25}] But any change in the plotting or table limits will give the" kernel exited" beep. This error or bug, with only a beep and the" kernel exited" message is typical for v10. on OS X10.10? I get this a lot of times using e.g. ParametricPlot3D. never got anything like this before.
Posted 8 years ago
 This looks like it was also asked on Stack-Exchange (http://mathematica.stackexchange.com/questions/87746/regionintersection-fails-for-some-values-with-polygons). Try using rational numbers instead of floating point numbers:b = 15; d = 4; lbp = 40; d1E = 2; l1E = 7; d1D = d1E; l1D = 5;r1 = Polygon[{{0, 0}, {lbp/2 - l1D, 0}, {lbp/2, d1D}, {lbp/2, d}, {-(lbp/2), d}, {-(lbp/2), d1E}, {-(lbp/2) + l1E, 0}}]; r2[c] := Rectangle[{-11/10 lbp/2, -15/10}, {11/10 lbp/2, c}]; r3[c] := RegionIntersection[r1, r2[c]];Area[r3[4/10]]292/25