Sign in to follow this  
hydraman

eel agent - water friction

Recommended Posts

Hi All, Quite a few months back, I posted this thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=480063 Well basically, I'm still stuck with it. Since I'm not as mathematically minded as I should be, a step by step guide (with possible pseudocode), would be great a bonus and hugely appreciated. So, who's up for the challenge? :-) Thanks, Ben.

Share this post


Link to post
Share on other sites
Basically I have implemented a 3D wireframe graphics engine and physics model, an example of which is the agent shown in the video linked in the previous thread.

Here it is again, in case you didn't visit the thread:

http://www.cs.bham.ac.uk/~bhj/movies/undulatoryX.mpeg

So the above undulatory mechanism is the type of behaviour I am interested in. Generating it, given the model, is straight forward (a collection of mass points connected by springs which can be compressed in pre-defined regular patterns).

Now my problem is, as I outline in the prior thread, is how to model the effect of water (friction of the water - drag and viscosity, etc, made on the agent). In the video above, the forward movement is a given, because all I do for each block segment is multiply a forwards directional vector by the magnitude of the velocity of that particular segment.

But, clearly this approach is not realistic since it means that the agents will always travel forwards no matter what. Previous work on the area, for example, that by Ijspeert, would suggest decomposing the velocity in to its normal and tangential components, but in 3D, and where the surfaces are not rigid (because they are the result of variably compressed springs), this is not trivial.

I have further consulted Scott McMillans thesis on Dynamechs, but I have really struggled with the mathematics.

Simply put, my mathematical expertise, in so far as 3D geometry and transformations go, I fear, is simply not good enough for me to implement the frictional effect of water.

If anybody thinks this is easy, please explain, I'm an idiot :-)

Ben

Share this post


Link to post
Share on other sites
So let me elaborate even further:

A segment is a `cuboid' constructed out of 8 mass points. These mass points are connected by springs and also there is `crane-like' structure of springs to prevent the segment from collapsing in on itself.

The animat is constructed out of N of these segment cuboids.

Now, since each segment has 8 mass points, there are 8 velocities for each segment. My first though was to compute the average velocotiy of the segment:

sum of all vecloties divided by 8 = W

And then to apply a simple friction force

do W *= -dv

Where d is drag and v is velocity, (EDIT: v is viscosity, not velocity) and then apply W as a force to each of the mass points. In other words, the environmental force yielded by the water is proprotional to the veclocity of the moving segment.

Now the problem as I see is, is that, its not the individual velocity of a mass point that I should be interested in, but rather of the whole segment, and then, each `face' of the segment. Further, when this segment has a particular velocity, it may or may not be pushing against the water.

So I need to know how to compute, the velocity of the face, and when it is 'pushing against' the water. From this, I think it will be easier to compute W

Ben

[Edited by - hydraman on October 13, 2008 10:30:28 AM]

Share this post


Link to post
Share on other sites
It sounds like you need to find the normal of each face of the segment and compare it to the average velocity (or something better?) of the face. I'm not that experienced, but you can try this:

You only need three points for this (a triangle defines a plane). Make two vectors from one point going each to a different point on the face. Then take the cross-product to get a vector normal to the face (direction matters here). Normalize this to get your normal vector. Then take the dot-product with the face's (average) velocity vector. Now you have the magnitude of the velocity that is perpendicular to the face. Use this with whatever drag formulas/coefficients you want. I think 'pressure drag' would be quadratic in velocity and 'viscous drag' would be linear.

Does that help at all?

Share this post


Link to post
Share on other sites
Taking the normal sounds about right - but you mention that "direction matters here". Just so I understand - do you mean that the vector generated by the cross product of two of the points on the "face" i.e. the "normal" could be on either side of the face plane? I mean, I only want the normal when the face is pushing against the water if that makes sense....because there should be no force against it if the face is moving 'away' from the water...


Hmmm....does that make sense?


So I see your method of generating the normal velocity component, but sometimes this normal will not be pushing against the water, but will be moving away from it....I'm a bit confused as to how to determine whether the face is 'pushing against' the water


I will iteratively try these suggestions tomorrow and post videos demonstrating my progress, so for any further comments people have (now, or then) , they can help :-)


Thanks,

Ben.

Share this post


Link to post
Share on other sites
Good, I'm glad that's what you're after. That's what I meant. You somehow have to make sure that your normal is pointing outward and not inward. There's a convention in OpenGL about which orientation your polygons should be in. If your points are in a counter-clockwise order, then the polygon is facing you. If you know that, then you just take the appropriate cross-product (AxB or BxA).
My example/pseudocode:
3 points (position vectors) - p1, p2, p3 - counter-clockwise order
2 vectors,
A = p2 - p1
B = p3 - p1
Cross them,
C = AxB
Normalize it,
D = C/|C|
Dot that with overall velocity,
E = v.D

If E is positive, then the face is pointing in the same direction that the object is traveling in; stationary water is hitting the face. If E is negative, do nothing, because the face is pointing away from the oncoming water.
E is now a magnitude factor for your applied force.

There ya go!

[Edited by - grimfang4 on October 14, 2008 12:06:31 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this