找到由另外两个相交形状创建的形状

发布于 2024-09-27 20:02:44 字数 406 浏览 0 评论 0原文

我的 C# 应用程序中有两个重叠的形状,由点数组定义。我需要找到定义这两个重叠形状的点。在此图像中,我知道红色和绿色点,但我需要黄色点。

alt text

这里有一些可能有帮助的虚拟代码:

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

    return yellow;
}

假设有简单的矩形,当然有一些方法可以做到这一点。在实践中,我需要能够处理多边形,甚至可能是圆形(尽管我可以没有圆形)。

有什么想法吗?我希望有一个漂亮的 GDI+ 函数可以解决这个问题。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Smile简单爱 2024-10-04 20:02:44

听起来像 Region::Intersect< /code>方法执行您想要的操作。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文