如何任意扭曲纹理多边形?
我想编写一个程序,让我可以通过拖动顶点来任意扭曲纹理多边形。我希望纹理能够流畅地扭曲且不重叠,假设新的多边形不与自身相交。我还应该能够用新的形状重复这个过程,并且损失最小。
有什么算法可以做到这一点吗?
I'd like to write a program that lets me arbitrarily distort a textured polygon by dragging its vertices. I want the texture to distort fluidly and without overlap, assuming the new polygon doesn't intersect itself. I should also be able to repeat the process with the new shape, and with a minimum amount of loss.
Are there any algorithms for doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您可能需要 Schwarz-Christoffel 映射 的变体。这是一种共形映射,可用于将多边形扭曲到更简单的区域(例如磁盘)或从更简单的区域扭曲多边形;虽然我还没有实现它,但显然它在计算上是易于处理的。
对于您的应用程序,您将设置从原始多边形到更简单区域的映射,并计算到修改后的多边形的逆映射;将两者结合起来应该可以为您提供从原始多边形到修改后的多边形的良好共形映射。
共形映射很好且平滑,但有时它们的行为方式可能不直观;我可以想象动画版本可能会产生一些有趣的“滑动”效果。共形映射将保留多边形内部的局部角度;这意味着修改顶点附近的尺寸扭曲可能会很严重。
It sounds like you might want a variation on the Schwarz-Christoffel mapping. This is a type of conformal mapping that can be used to warp a polygon to and from a simpler region, like a disk; although I have not implemented it, apparently it is computationally tractable.
For your application, you would set up a map from the original polygon to the simpler region, and compute the inverse map to the modified polygon; combining the two should give you a nice conformal mapping from the original to the modified polygon.
Conformal mappings are nice and smooth, but they can sometimes behave in unintuitive ways; I can imagine that an animated version might yield some entertaining "slidy" effects. The conformal mapping will preserve local angles in the interior of the polygon; this means that the size distortion very near a modified vertex can be severe.
在过去的一两年里,人们一直在致力于解决这个问题,并且最先进的技术不断变得越来越好(但数学也变得越来越难)。一个很好的起点(也是我停止关注它的地方)是工作 http://www.cs.technion.ac.il/~weber/Publications/Complex-Cooperatives/
阅读那里的论文,并在参考文献中查找论文。其中之一应该为您提供一种您愿意实现的算法。
People have been working on solutions to this problem for the past decade or two, and the state of the art keeps on getting better and better (but the math gets harder as well). A good place to start (and sort of where I stopped following it) is the work http://www.cs.technion.ac.il/~weber/Publications/Complex-Coordinates/
Read the paper there, and look up the papers in the references. One of them should give you an algorithm that you're willing to implement.
我能想到的最简单的方法是对输入多边形进行三角测量(使用耳朵裁剪方法或类似的方法),然后移动点。然后,您可以使用从原始多边形到新空间的重心映射。
如果您正在寻找更可靠的东西,您可以查看平均值坐标。
The simplest method I can think of is to triangulate the input polygon (using an ear clipping method, or something similarly good) and then move the points. Then you can use a barycentric mapping from the original polygon to the new space.
If you're looking for something more robust, you might look at mean value coordinates.