TransWikia.com

Determine if intersection of Polygon and HalfLine is non-empty

Mathematica Asked on June 27, 2021

I have a concrete example:

BooleanRegion[#1 && #2 &, {
  Polygon[{
    {1, 2},
    {-1, 1},
    {-2, 1},
    {0, 0}
    }]
  ,
  HalfLine[{0, 1}, {1, 0}]
  }
 ]

This does not simplify at all, even though it should be easy. However,
If I discretize both the polygon and half-line, then I get a line segment as output.
Now, I am not really interested in the actual intersection, only if they intersect or not.
Seems like discretizing the regions is a bit over-kill, is there some more efficient way
to determine if a half-line intersects a given polygon?

EDIT: Note that it sometimes works, I suspect it works if the polygon is convex. In the example above, the polygon is non-convex, but change the vertex (-1,1) to (-1,3) and the intersection is computed as expected.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP