1
$\begingroup$

I am having trouble finding the intersection of an infinite line and an irregular RegionBoundary. Mathematica cannot return DiscretizeRegion.

Any suggestions?

Irregular Polygon with infinite line

Irregular Polygon

perimeterOfArea = 
   RegionBoundary[Polygon[perimeterPoints[[All, 1 ;; 2]]]];

regionTwo = RegionIntersection[
   perimeterOfArea, 
   InfiniteLine[{894400, 2.7675*10^6}, {1, 0}]
];

DiscretizeRegion[regionTwo]

DiscretizeRegion::drf: DiscretizeRegion was unable to discretize 
the region RegionIntersection.
$\endgroup$
2
$\begingroup$

Just for illustrative purposes:

m = DelaunayMesh[RandomReal[1, {15, 2}]];
b = RegionBoundary[m];
f[p1_, p2_] := 
 Module[{line = InfiniteLine[{p1, p2}], mp = MeshPrimitives[b, 1], ri},
  ri = (RegionIntersection[line, #] & /@ mp) /. 
    EmptyRegion[_] :> Sequence[]; 
  If[Length@ri > 0, ri, {}]]
Manipulate[
 Module[{i = f[p, q]},
  Show[
   Graphics[{InfiniteLine[{p, q}], Red, PointSize[0.02], i}, 
    PlotRange -> Table[{0, 1.25}, 2], 
    PlotLabel -> (i /. Point[x_] :> {x})], b]],
 {{p, {0.1, 0.1}}, Locator}, {{q, {0.4, 0.4}}, Locator}]

enter image description here

$\endgroup$
1
$\begingroup$

Instead of generating the RegionBoundary of a Polygon, you could consider constructing a Line from your set of points.

For instance:

points = CirclePoints[8];
line = Line@ Join[points, points[[{1}]]];
il = InfiniteLine[{{0.5, 0.5}, {1.5, 0.5}}];

RegionIntersection[line, il]
(* Point[{{-0.806563, 0.5}, {0.806563, 0.5}}] *)

In this simple example, taking the region boundary of the polygon is equivalent to generating the line from its points:

line === RegionBoundary[Polygon@ points]
(* True *)

Although in your case it is not (an expression with head MeshRegion rather than Line is output from RegionBoundary), this alternative may work for your data.

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