Possible Duplicate:
A simple algorithm for polygon intersection
I'm looking for an outline on how to quickly calculate the intersection of two arbitrarily oriented quadrilaterals (no preset corner angle or side length constraints). I am not looking to simply check whether they intersect, but wish to get the points making up the resulting intersecting region. I know that in general polygon intersection isn't a trivial problem and there are libraries available that do a good job.
But since in this special case where I'm only concerned with four sided shapes, I was wondering if there was a quick method I could use without including an entire additional library in my application.
So far all I've thought of is:
- Run 'point in polygon' on both shapes with respect to each other
- Intersect each edge of each polygon with each other
Do the above two steps definitively get me all the points that make up the resulting intersection region? Is there a better method to use?
Also it would be nice if I could get the correct ordering of the points that make up the resulting region. It's not mandatory -- if you are aware of any clever/quick ways of doing this bit (convex hull?) I'd appreciate any suggestions.