Box2D Forums

It is currently Sat May 25, 2013 7:26 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Polygon clipping
PostPosted: Mon Sep 29, 2008 5:09 pm 
Offline

Joined: Thu Apr 24, 2008 2:09 pm
Posts: 91
This is more of a geometry question than a physics one, but it relates to my attempts to make breakable objects, as described in this thread: http://www.box2d.org/forum/viewtopic.php?f=3&t=1401&st=0&sk=t&sd=a Maybe someone knows about this kind of thing, and can help.

Cue poorly-hand-drawn and photographed image... It was easier for me than drawing it on the computer, and hopefully gets the point across:

Image

Shape A is a convex shape with an arbitrary number of edges/verts (but, if it helps, I can make it a low maximum number, like 8). Shape B may or may not be concave. Depending on which makes the maths easiest, I can define either shape as just their outside points (clockwise or anti-clockwise), or as a "triangle soup" that makes up the object.

What I want to work out, is that when A intersects B, to get some kind of workable description of C (either as the outside edge points, or as a "triangle soup"), which is the shape that's left from subtracting A from B. How might I go about doing something like that? Scissoring something to a rectangle is relatively straightforward, but I don't know how to go about doing something like this.


Top
 Profile  
 
 Post subject: Re: Polygon clipping
PostPosted: Sat Oct 04, 2008 1:41 am 
Offline

Joined: Fri Oct 03, 2008 1:37 pm
Posts: 22
I can't say this is the most efficient way to do it, but this is how I would do it. I would take each line segment of the intersecting object, and then use the line intercept formula and go over each line segment in the intercepted object, so line1 of interceptor would iterate over all line segments of the intercepted object then line2 and etc..(keep in mind some intercept points, naturally, won't be found). Then I would find all the points of the interceptor that are located withing the intercepted. That should give you all your points for your new object.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group