tags:

views:

63

answers:

1

I have two overlapping shapes in my C# app, defined by Point arrays. I need to find the points that define the shape where these two overlap. In this image, I know the red and green points, but I need the yellow points.

alt text

Here is some dummy code that might help:

Point[] GetIntersection(Point[] red, Point[] green)
{
    Point[] yellow = ?!?;

    return yellow;
}

There are certainly ways you could do this assuming nice easy rectangles. In practice, I need to be able to handle polygons and maybe even circles (although I can live without circles).

Any ideas? I'm hoping there is a nifty GDI+ function that will just spit this out.

+4  A: 

It sounds like the Region::Intersect method does what you want.

RedFilter
@Miky - I tried it with a polygon and it worked fine (you have to create a `GraphicsPath` from the polygon point array).
Jon B