user27414
user27414

Reputation:

Finding the shape created by two other intersecting shapes

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.

Upvotes: 3

Views: 1445

Answers (1)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171431

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

Upvotes: 5

Related Questions