Jump to content
  • Advertisement
Sign in to follow this  

Drag problem

This topic is 4843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi...first of all sorry that the thread subject wasn't terribly descriptive as I don't know how to describe it in a short way... Now I just deleted all of this because it seems that the angular velocity suddenly becomes really big, causing the quaternion filled with _very_ small values which goes to NaN when normalized. Now I think it's my drag function which is wrong, as I found that putting (0,0,14.8600006) as the angular velocity caused it to output (0,0,-706)!! Here's the naughty thing:
public static void CalculateSphereDrag(Vector3 velocity, Vector3 angularVelocity,
                                       float sphereRadius, float fluidDensity,
                                       float linearDragCoefficient, float angularDragCoefficient,
                                       out Vector3 linearDrag, out Vector3 angularDrag)
	//Linear drag force - normalised drag vector * speed*speed * fluidDensity * LINEARDRAGCOEFFICIENT * radius*radius
	Vector3 dragDir = -velocity;
	float speed = dragDir.Length();
	linearDrag = dragDir * speed * fluidDensity * linearDragCoefficient * sphereRadius * sphereRadius;

	//Angular drag force -  - normalised drag vector * speed*speed * fluidDensity * ANGULARDRAGCOEFFICIENT * radius*radius
	dragDir = -angularVelocity;
	speed = dragDir.Length();
	angularDrag = dragDir * speed * fluidDensity * angularDragCoefficient * sphereRadius * sphereRadius;

and I called it with: Physics.RigidBody3D.CalculateSphereDrag(this.Velocity, this.VelocityAngularBody, this.BoundingSphere.Radius, 10, 0.5f, 0.5f, out linearDrag, out angularDrag); Maybe 10 is too big a fluid density? I know that the drag coefficients have to be 0-1 but does the fluid density have to be within a certain range too? What are the typical values for the parameters? (for, say, air or water) Thanks [Edited by - DrGUI on July 12, 2005 4:47:43 AM]

Share this post

Link to post
Share on other sites
Also, if you know of any online lists of fluid densities, friction coefficients etc can I have the links please?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

I think the problem with your code is that force is too big for considering the model as linear.
The things you have to do fix it are:
- reduce time steps
- reduce drage force : if you speak in international units, water density is 1000 kg/m3 and air density is 1 kg/m3
- if it's not sufficient, you should check that resulting velocity has same direction as initial one. If not, set resulting velocity to 0.

Share this post

Link to post
Share on other sites
Thanks AP, I tried reducing my time step however that didn't make any difference, and I can't get access to the resultant velocity as that's in my numerical integrator and it seems like a bit of a hack anyway.

I'm sure it's something wrong with my drag equation...

Thanks again, I would rate you if you weren't anomynous!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!