views:

117

answers:

3

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.

A: 

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

No one in particular
flocking algs usually refer to modeling the behaviour of a set with # > 1
belisarius
True, but maybe while reading about these topics he might come up with some ideas to try out that apply to his particular case.
No one in particular
Errrrrr,I am working on a project with only one fish,thank you anyway
suige
+1  A: 

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.

Nixuz
yeah,I never considered treat a fish as a tank,but you do bring me an good aspect for considering.
suige
A: 

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.

Pedery
pretty detailed ,thx!
suige