如何在二维矢量场中找到无限循环?
我有一个有限大小的二维矢量场。我想要的是找到这个领域中的任何“循环” - 也就是说,如果这个领域代表流体的流动,并且您将一个物体放在这些循环之一上,则该物体会一圈又一圈,永远不会到达休息。我想我已经找到了一些关于这个问题的学术数学文章,但它们超出了我的理解范围,我无法理解它们。是否有找到此类循环的标准算法?
为什么我要寻找这样的循环?我正在考虑制作一款与《超级马里奥银河》有类似概念的 2D 平台游戏,其中会有几个小的引力体,玩家可以在它们之间跳跃并在其上行走,而不是单个全局重力矢量。静态物体的重力场将在关卡编辑期间静态计算。我确实没有办法解决这个问题,但这将是一个非常好的工具,可以在关卡编辑器中检测不可避免的重力循环,而不必通过游戏测试来发现它们。
I have a finitely-sized 2D vector field. What I want is to find any "cycles" in this field - that is, if this field represented the flow of a fluid, and you placed an object on one of these cycles, the object would go around and around and would never come to rest. I think I've found some scholarly mathematical articles about this problem, but they're so far over my head that I can't make any sense of them. Is there a standard algorithm for finding such cycles?
Why do I want to find cycles like this? I'm considering making a 2D platformer that has a similar concept to Super Mario Galaxy, in that there will be several small gravitating bodies that the player can jump between and walk on, rather than a single global gravity vector. The gravity field for the static bodies would be computed statically during level editing. I don't really have to solve this problem, but it would be a very nice tool for detecting unescapable gravity loops in the level editor rather than having to discover them through playtesting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难想象一个包含循环的“重力场”。然而,玩家的轨迹可能是循环的。我们称之为“轨道”。
一个简单的解决方案可能是加入少量的摩擦或阻尼,以确保轨道衰减。
一个不太容易处理的解决方案:如果空间是离散的,那么您可以测试每个状态(位置、速度)并检查玩家是否重新访问相同的状态。请注意,这还需要有限数量的合法速度值。
从可用性的角度来看,为玩家提供一些推进手段也是解决问题的好方法。
It's hard to imagine a "gravity field" that contains cycles. However, the trajectory of the player might be cyclic. We call this "orbit."
An easy solution might be to include a small amount of friction or dampening to ensure that orbits decay.
A less tractable solution: if the space is discrete, then you can test each state (position,velocity) and check if the player ever re-visits the same state. Note that this would also require a finite number of legal velocity values.
From a usability perspective, giving the player some means of propulsion would also be a nice way to solve the problem.