So I have a set of Polygon
s that I'm obtaining from some ImageJ measurements, and I'd like to sequentially find the intersection points of systematically placed horizontal lines with these polygons.
I'm using the following (simplified) code once the polygons have been rotated and translated to the origin.
Here are the coordinates of an example polygon:
{{-74.0165, 299.034}, {-71.8493, 229.211}, {-37.9741,
149.258}, {-33.4983, 86.2663}, {-36.5136, 35.7597}, {0.,
0.}, {31.0483, 0.0471143}, {60.6361, 28.6926}, {69.8234,
87.0672}, {75.6655, 142.474}, {75.3829, 243.864}, {82.2615,
295.407}, {57.5737, 348.834}, {13.8516, 380.589}, {-31.6137,
372.533}, {-71.0012, 349.541}}
And a snippet of how I'm trying to extract the intersection points:
rods = Table[
Polygon[wholeRodCoords[[i]]],
{i,1,Dimensions[wholeRodCoords][[1]]}
];
il = InfiniteLine[{{0,1},{1,1}}];
intercepts = RegionIntersection[rods[[1]],il];
Which results in this output:
BooleanRegion[#1&&,{Polygon[],InfiniteLine[{{0,1},{1,1}}]}]
but no discrete points.
If I try a toy example:
poly = Polygon[{{0,0},{1,4},{2,2},{3,-1}}];
line = InfiniteLine[{{1,2},{2,2}}];
RegionIntersection[poly,line]
I get the following expected output:
Line[{{1/2,2},{2,2}}]
So, my primary questions are these:
- Is there a better way to do what I'm trying to do?
- If not, why is this behavior occurring? I'm not really able to troubleshoot why these expressions are incompatible.
- What is a possible solution to this behavior?
RegionIntersection[rods[[1]], DiscretizeRegion @ il]
? $\endgroup$