Sign in to follow this  
cnboy0212

point of intersection with 2D polygons

Recommended Posts

Supposedly there are 2 polygon, let's say they are both convex, and supposedly they are colliding with each other. How do i find where are they colliding? Basically i want a way to find the intersection(s) of their edges. ~thanks

Share this post


Link to post
Share on other sites
Intersection of convex polygons is implemented in the Wm4ConvexPolygon2.* files at my Mathematics page. In particular, look at the functions FindIntersection (intersection of two convex polygons) and FindAllIntersections (intersection of multiple convex polygons). The algorithm uses clipping one polygon against each edge of the other polygon. (There is an asymptotically faster method; see Joseph O'Rourke's book "Computational Geometry in C".)

Share this post


Link to post
Share on other sites
I am using Java to program, but that shouldn't matter since programming languages are alike, but one think i don't get is that the findIntersection method returns a boolean, but what I am trying to find a the point at where they intersect, not if they are intersecting or not.

Share this post


Link to post
Share on other sites
The 'bool' return indicates whether or not there is an intersection. The last parameter of the function is an "output" parameter and stores the convex polygon of intersection. The simplest choice for a point of intersection is one of the output polygon's vertices.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this