Sign in to follow this  

How to converse tangential velocity

Recommended Posts

Hey, I'm trying to write a hair simulation program at the moment and have come stuck on a little math problem that I'm hoping someone can help me out with. I want the strands of hair to "slide" over the head so I think I need to keep any tangental velocity of the strand when it collides with the hair. At the moment I'm just moving the strand out of the collision and zeroing it's velocity as so...
p1 = strand.Links[i].Position; 
//Move link out of head and zero movement.  
p1Dash = p1 + (contactNormal * (contactDepth)); 
strand.Links[i].PhysicsEntity.centerPosition = p1Dash; 
strand.Links[i].PhysicsEntity.linearVelocity = Vector3.Zero; 
strand.Links[i].PhysicsEntity.linearMomentum = Vector3.Zero; 
strand.Links[i].PhysicsEntity.angularVelocity = Vector3.Zero; 
strand.Links[i].PhysicsEntity.angularMomentum = Vector3.Zero; 
I figure I need to conserve the tangental velocity somehow, but I'm not sure how to go about this (how do I find the appropriate tangent, what do I cross etc...) Here are some diagrams to illustrate the problem. This picture is what I think I need. I need to send the colliding particle along the collision plane's tangent in order to have it move "around" the object. These are some picture of what I have at the moment. In the first slide you can see the bunching of the links as they are just stopped solid. The second slide shows some progress but this progress is very bumpy as the position of the link is simply pushed out at each frame. Finally, the 3rd slide shows the end result by just pushing out the links. Not bad, but it doesn't look good in motion. [Edited by - SmellyIrishMan on April 3, 2010 8:46:00 AM]

Share this post

Link to post
Share on other sites
So I got around to messing about with this again today and managed to come up with this;

originalVelocity = strand.Links[i].PhysicsEntity.linearVelocity;
normalisedVelocity = new Vector3(originalVelocity.X, originalVelocity.Y, originalVelocity.Z);
strand.Links[i].PhysicsEntity.linearVelocity = originalVelocity - (contactNormal * Vector3.Dot(contactNormal, normalisedVelocity));
strand.Links[i].PhysicsEntity.linearVelocity *= 0.9f;

So I'm checking the angle of penetration and removing this from the velocity in order to just get the tangential quantity. The simulation runs a whole lot smoother now anyway, so I'm happy.

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