如何任意扭曲纹理多边形?

发布于 2024-08-22 07:47:01 字数 116 浏览 4 评论 0原文

我想编写一个程序,让我可以通过拖动顶点来任意扭曲纹理多边形。我希望纹理能够流畅地扭曲且不重叠,假设新的多边形不与自身相交。我还应该能够用新的形状重复这个过程,并且损失最小。

有什么算法可以做到这一点吗?

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 技术交流群。

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

发布评论

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

评论(3

月隐月明月朦胧 2024-08-29 07:47:01

听起来您可能需要 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.

旧街凉风 2024-08-29 07:47:01

在过去的一两年里,人们一直在致力于解决这个问题,并且最先进的技术不断变得越来越好(但数学也变得越来越难)。一个很好的起点(也是我停止关注它的地方)是工作 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.

波浪屿的海角声 2024-08-29 07:47:01

我能想到的最简单的方法是对输入多边形进行三角测量(使用耳朵裁剪方法或类似的方法),然后移动点。然后,您可以使用从原始多边形到新空间的重心映射。

如果您正在寻找更可靠的东西,您可以查看平均值坐标。

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.

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