找到由另外两个相交形状创建的形状
我的 C# 应用程序中有两个重叠的形状,由点数组定义。我需要找到定义这两个重叠形状的点。在此图像中,我知道红色和绿色点,但我需要黄色点。
这里有一些可能有帮助的虚拟代码:
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.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来像
Region::Intersect< /code>
方法执行您想要的操作。
It sounds like the
Region::Intersect
method does what you want.