Intersect Polygon and Segment
- Ryan Hirst
Tool (.ggt): http://www.geogebratube.org/material/show/id/97764 I continue to use the same definition of inside as IsInRegion. (more: http://www.geogebratube.org/student/m96425). Drag point M to see if GGB agrees with how it has shaded Jerome. I think you will find the orange segments and M always agree.
Let vector u = (Q-P). and let an intersection X on line PQ be of the form: (1) . Then t > 0 : X is on ray PQ 0 < t < 1 : X is on segment PQ If t= 0 or 1, P or Q falls on the perimeter of Jerome. I have not yet distinguished these cases as intersections. Question: What is the rule for drawing segments? If P or Q falls inside the polygon, it is the endpoint of an orange segment, but should not be included in the intersection list. Also, I calculated intersections in the direction P --> Q, and I don't want to recalculate them from Q, or resort my lists. Parity: Consider the evaluation of some number k: (2) GGB: k'= Mod[k,2] If k is even, k'=0. If k is odd, k'=1. I will call the property even/odd parity. For example, the evaluation (3) Mod[k, 2] ≟ Mod[m,2] is true if k, m have the same parity (both even or both odd), and false if their parities differ (one is even and the other odd). If they both go to different parties, I will not measure that quantity, but get out a paper crown and dance. Then Let k = # intersections on ray PQ, m = # intersections on segment PQ. Rules: P: If k is odd, P is inside. Q: If k and m have different parity, Q is inside: