Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Can someone help me?

I want to cut a polygon with another one...
Do you know an algorithm?

Thank you all.
Posted
Updated 9-Dec-10 9:26am
v2
Comments
CPallini 9-Dec-10 15:27pm    
Could you be more specific? What do you really need?
AspDotNetDev 9-Dec-10 15:32pm    
Do you mean cut out a portion of one polygon by overlaying another polygon on top of it and removing the section that overlaps? Would the result be the overlapping area, or would the result be the remainder of the first polygon (i.e., the portions of the first polygon that were not overlapped by the second)? And are we talking about simple polygons here, or are we talking about things like a square that is missing a small circular portion from its center (that would be a surface rather than just a polygon)?

1 solution

Hi,

I will give you a rough idea how it could be. By the way it is my own idea and not referring to any existing popular algorithm.

When take two polygons which intersects there are some node (point) must be inside the other polygon. So on a loop find the point inside using the point in polygon algorithm. So let us say a point inside a polygon and the next node is outside the polygon then it must be intersecting the vertex of another polygon. Find the intersection points and rearrange the point order to create the new intersected polygon. Hope this would helps. If you feel it make sense I will try to write some coding.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900