there is a link to my problem, something i drew up real quick. i am trying to find an area of a polygon inside a rectangle by way to getting the intersecting points and throwing out all the rest. my code works up to that point and was looking until i discovered that i really wasnt calculating all of the shape.

Via the image you can see that at point (8,10) there is an intersection then again the next intersection at (5,5). naturally adding this point to the list of points inside the rectangle would be obvious in later calculating the area but as i discovered i am missing the area(with green lines) as i simply cannot “draw” a straight line between (8, 10) and (5,5). clearly i am missing the corner of the rectangle.

my question is, is how would i calculate how much of the area i missed? Ideally it would be nice to have the “rectangle” as always a rectangle and always have 4 corners with 4 points but unfortunately i cannot rely on this to always be the case. To make things easier to understand i just made an example by drawing a rectangle but i figured by solving this for a rectangle might be useful is irregular shapes as well.

anyway thanks for your time!