How to converse tangential velocity

Started by
0 comments, last by SmellyIrishMan 14 years ago
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.Position; 
 
//Move link out of head and zero movement.  
p1Dash = p1 + (contactNormal * (contactDepth)); 
strand.Links.PhysicsEntity.centerPosition = p1Dash; 
strand.Links.PhysicsEntity.linearVelocity = Vector3.Zero; 
strand.Links.PhysicsEntity.linearMomentum = Vector3.Zero; 
strand.Links.PhysicsEntity.angularVelocity = Vector3.Zero; 
strand.Links.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. http://img522.imageshack.us/img522/556/physicsquestion.png 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. http://img515.imageshack.us/img515/7173/physicsquestionprograme.png 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]
Advertisement
So I got around to messing about with this again today and managed to come up with this;

originalVelocity = strand.Links.PhysicsEntity.linearVelocity;
normalisedVelocity = new Vector3(originalVelocity.X, originalVelocity.Y, originalVelocity.Z);
normalisedVelocity.Normalize();
strand.Links.PhysicsEntity.linearVelocity = originalVelocity - (contactNormal * Vector3.Dot(contactNormal, normalisedVelocity));
strand.Links.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.

This topic is closed to new replies.

Advertisement