Sign in to follow this  

Drag problem

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
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

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