Skip to main content
GameDev.net gamedev.net
🔒 Locked

Polygon Intersection

Started by NMO Mar 11, 2007 at 1:48 PM 7 replies 4.1k views
Original Post
NMO
NMO
Hi! I have two arbitrary polygons . When there is an intersection between these polygons, the first polygon should cut off the intersection area of the second polygon. To give a better experience I have drawn some example pics: Pic1 Pic2 Pic3 Pic4 Pic5 Pic6 Pic7 The red cicled vertices have to be added to the 2. polygon. The green cicled vertices have to be deleated. I am able to calculate these vertices already, but the problem is how to connect the new red vertices. Now the problem is that I don't know how to connect the red vertices, as I can't determine the sequence. I have drawn another example to emphasize the problem. There are many new red points which should be added to the polygon, but I can't determine in which sequence. Pic8 If I haven't something precisely explained, please let me know.. Thanks in advance. [Edited by - NMO on March 11, 2007 3:21:03 PM]
Zakwayda
Zakwayda
Your links aren't working for me (Firefox, OS X). The image is drawn, but is then immediately replaced by an error message.

Also, you can link directly to the images using the HTML 'img' tag.
NMO
NMO
Sorry for that, i have fixed it.
NMO
NMO
Can't really nobody help me :(
smitty1276
smitty1276
Based on your drawings alone, it's hard to tell if the polygons are coplanar. Are they arbitrarily oriented in 3D space, or are they coplanar?
NMO
NMO
They are coplanar.
smitty1276
smitty1276
I would say that you should start by detecting the intersections of the line segments formed by adjacent points on the polygons. Once you have found those you can eliminate the interior ones.
Gagyi
Gagyi
Lets see.
Add the intersection points to both of the polygons. (this means plus one point on the line segment)
Store wich points on the polys are from intersection.
Now start to traverse through the points of one of the poly.
Start with an interior point, and go CCW.

while (not got back to the starting point) do
_go to the next point
_if (this point is an intersection point) then continue with traversing the other poly //(jump to the corrsponding point on the other poly)
end loop

I made a "comic" for better understanding.
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
NMO
NMO
Wow, thats amazing.
Now everything is clear, thank you very much :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.