如何找到位于多边形凸包轮廓上的所有点(Matlab)
抱歉,如果这个问题看起来很简单,但我无法弄清楚。
想象两个随机重叠的任意矩形,以便它们的轮廓仅在两个位置相交。现在,您从矩形 1 中切掉重叠区域。
这个“被咬住的矩形 1”现在具有以下点(顶点): (1) 位于矩形 2 外部的矩形 1 的所有点,(2) 矩形 2 的所有点位于矩形 1 和 (3) 两个交点内。
知道的问题如下:如何获得新点的顺序,以便函数plot(...) 或fill(...) 绘制正确的“咬矩形1”?
到目前为止我做了什么: 我确定了位于矩形 2 + 交点之外的所有点的凸包。然后,必须按照正确的顺序在第一个和第二个交点的索引之间添加位于矩形 1 内(由于与矩形 2 重叠)的新点。
这种凸包方法的问题在于,它仅在交点位于矩形 1 的不同线上时才有效,因为这样它们就是凸包的一部分。 如果它们位于同一条线上,则它们不再被视为凸包的一部分。
我需要的是一种方法来获取凸包上所有可能点的顺序,而不仅仅是最外面的点。
希望有人能帮助我... 先感谢您, 帕特里克
sorry if this question might seem simple but I couldn't figure it out.
Imagine two arbitrary Rectangles that are randomly overlaped so that their outlines intersect at only two locations. Now you cut the area of overlap out of Rectangle 1.
This "bitten Rectangle 1" has now the following points (vertices): (1) All points of Rectangle 1 that lie outside of Rectangle 2, (2) All points of Rectangle 2 that lie inside Rectangle 1 and (3) the two intersection points.
The problem know is the following: How can I get the order of the new points so that the functions plot(...) or fill(...) would draw the right "Bitten Rectangle 1"?
What I did so far:
I determined the convex hull of all the points that lie outside of Rectangle 2 + the intersection points. Then one has to add the new points that lie inside rectangle 1 (due to overlap with Rectangle 2) between the indices of the first and second intersection point also in the right order.
The problem with this convex hull approach is that it only works if the intersection points lie on different lines of Rectangle 1, because then they are part of the convex hull.
If they lie on the same line they are no longer treated as part of the convex hull.
What I'd need is a method to get the order of all possible points that lie on the convex hull and not only the outer most ones.
Hope anybody can help me...
Thank you in advance,
Patrick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Matlab 中,有一个名为
polybool
的神奇函数,可以让您对多边形执行任何设置操作:http://www.mathworks.com/help/toolbox/map/ref/polybool.html您所要做的就是定义四个描述矩形的数组 (rect1x 、 rect1y、 rect2x 和 rect2y) 并调用
[resultx resulty] = polybool('subtraction', rect1x, rect1y, rect2x, rect2y)
。生成的数组将描述“咬住的矩形 1”。In Matlab, there is an amazing function called
polybool
that let you do any set operation on polygons: http://www.mathworks.com/help/toolbox/map/ref/polybool.htmlAll you have to do is to define four arrays describing the rectangles (rect1x, rect1y, rect2x and rect2y) and to call
[resultx resulty] = polybool('subtraction', rect1x, rect1y, rect2x, rect2y)
. The resulting arrays will be describing the "Bitten Rectangle 1".