Intersect Polygon and Ray
- Ryan Hirst
Tool (.ggt): http://www.geogebratube.org/material/show/id/96426
Fair warning: the Sequence and Zip objects are pretty hairy. In short,
- Calculate all the intersections of line P with the perimeter. For example, to intersect line P with the line through A1, A2: And the intersection lies on segment a1 if Discard all intersection times outside the range 0...1.
- For each valid intersection, find the corresponding values of λ, on the line. We have a ray, so remove all negative values of λ.
- Sort the remaining values λ least to greatest (distance from P), keeping track of which segment corresponds to each value. Following convention (and the definition used by IsInRegion), we have a consistent rule for partitioning the ray into intervals Inside and Outside the polygon (http://www.geogebratube.org/material/show/id/96425)