优化顶点时如何避免多边形变得复杂?
假设有一组 2D 点来表示初始简单多边形。现在我想根据一些成本函数优化每个点的位置。但这可能会使多边形变得复杂,即多边形与自身相交。我怎样才能避免这种情况?谢谢!
Suppose there's a set of 2D points to represent an initial simple polygon. Now I want to optimize the positions of each point according to some cost function. But this could make the polygon complex, i.e. the polygon intersects with itself. How can I avoid this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果可以假定多边形是凸多边形,那么它就很简单。只需计算每条边与下一条边之间的角度即可。对于凸多边形,每个角度必须介于 0 到 180 度之间。对于具有 N 条边的闭合多边形来说,这些角度的总和是众所周知的。这将导致简单的约束优化。 (实际上,您可以以比用三角函数计算角度更“简单”的形式编写这些约束。叉积就足够了。)
如果多边形不需要是凸的,那么您需要担心边交叉或其他简并性。
If the polygon could be presumed to be convex, then it is simple. Simply compute the angles between each side and the next side. Each angle must be between 0 and 180 degrees for a convex polygon. The sum of those angles is well known for a closed polygon with N sides. This will result in a simple constrained optimization. (Actually, you can write those constraints in a "simpler" form than computing the angles with a trigonometric function. Cross products will suffice.)
If the polygon need not be convex, then you need to worry about edges crossing, or other degeneracies.