生成 3 维随机路径

发布于 2024-09-27 05:47:52 字数 107 浏览 5 评论 0原文

当我正在从事一个需要模拟鱼的运动的项目时, 我将鱼置于 3D 环境中,我希望它能够像真正的鱼一样在一条路径中游泳。 我想知道是否有任何算法可以生成准随机的、类似鱼的路径?

祝大家好运。

while I am working at a project that requires simulate the movement of a fish,
I put the fish in a 3D environment and I wish it could swim in a path looks like a real fish will do.
I am wondering if there is any algorithm that can generate a quasi-random, fish-like path?

best wishes,everyone.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

避讳 2024-10-04 05:47:52

Javascript 中的鱼模拟(源代码可用)模拟鱼在二维空间中的运动;然而,它可以很容易地修改为三维。您应该让系统进化鱼神经网络大脑,以便看到完整的效果或观看页面上发布的视频。

鱼的移动方式与具有两个踏板的水箱类似,其中给出两个速度变量,允许鱼根据速度变量之间的差异旋转或向前移动。给出了一些参数,这样鱼就不会急剧转向。对于每个时间步,鱼的加速度值由神经网络(通过进化训练)针对每个“踏板”给出,该神经网络使用牛顿定律影响鱼的踏板速度。你可以做一些更随机的事情,而不是使用神经网络;但是,您需要将鱼的数量减少到非常小的范围。

This fish simulation in Javascript (source code available) simulates fish movement in two dimensions; however, it would be easily modified to three dimensions. You should let the system evolve the fish neural network brains in order to see the full effect or watch the video posted on the page.

The fish move in a similar way as tank with two treads, where two speed variables are given allowing the fish to rotate or move forwards depending on the difference between the speed variables. Some parameters are given so the fish can't turn overly sharply. For each time step the fish acceleration values are given by a neural network (trained by evolution) for each of the "treads" which using Newtons laws effects the tread speed of the fish. Instead of using a neural network you could do something more random; however you would need to reduce the amount the fish can turn to a very small range.

×眷恋的温暖 2024-10-04 05:47:52

我曾经编写过一个有趣的程序,其中我生成了随机移动的蠕虫。如果您不寻找太复杂的东西,那么可以肯定您可以在您的情况下使用相同的方法。不过,我的尝试是一个非常简单的启发式方法。该解决方案适用于 2D,但您可以轻松地将其扩展到 3D。

我将创建一个概率矩阵,指示 Fish[n] 在迭代 i+1 中向每个方向移动的概率,例如:90% 表示保持朝同一方向移动,2% 表示向左转 45 度,右转 45 度为 2%,左转或右转 90 度为 1%,等等。此外,您还必须存储鱼当前移动方向的指示。这些百分比基本上是通过反复试验来解决的,但这微不足道。

如果您想要平滑的运动,您可以选择鱼将移动到距其当前位置一定距离的新点,并像 3D 空间中的贝塞尔曲线一样计算轨迹。

I once wrote a program for fun where I generated worms that moved randomly. Pretty sure you can use the same approach in your case if you're not looking for something too complex. My attempt was a pretty simple heuristic though. The solution was for 2D, but you can easily expand it to 3D.

I'd create a probability matrix indicating the probability that fish[n] would move in each direction in iteration i+1, for instance: 90% for keeping moving in the same direction, 2% for a 45 degree turn to the left, 2% for a 45 degree turn to the right, 1% for a 90 degree turn to the left or right etc. In addition you'd have to store an indication of what direction your fish is currently moving. The percentages were basically resolved by trial and error, but that's trivial.

If you want smooth movements, you could i.e. choose a new point the fish will move to that is some distance away from its current position, and calculate the trajectory like a Bezier curve in 3D space.

平定天下 2024-10-04 05:47:52

尝试谷歌搜索“集群算法”。生化机器人也是值得研究的东西。

Try Googling "flocking algorithm". Bioroids are also something to look into.

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