Air Resistance

Hi,
I am trying to simulate air resistance in Ode. But im having a bit of trouble doing it in a proper way that doesn’t affect alot of gravity stuff:


            if (airResistance < 1) {
                  javax.vecmath.Vector3f velocity = bod.getLinearVel();
                  javax.vecmath.Vector3f angVeloc = bod.getAngularVel();

                  velocity.x *= airResistance;
                  velocity.y *= airResistance;
                  velocity.z *= airResistance;

                  angVeloc.x *= airResistance;
                  angVeloc.y *= airResistance;
                  angVeloc.z *= airResistance;

                  bod.setLinearVel(velocity);
                  bod.setAngularVel(angVeloc);
            }

Seems a hack to me, and not the way i should be doing things…

Any ideas?

When working with physics models, forces are far better to model in rather than velocity - that’s why you’re using a physics model in the first place.

Air resistance should be calculated as a force. In general, air resistance is proportional to the square of the speed. Find out what your velocity is for the frame, calculate the airresistance in the exact opposite direction to the velocity, and add a force which is equivalent to the amount of power you’re getting from the engine providing forward motion.

right, ok.

So I have a force thats making a sphere move forwads, say 10 newtons. So i have to make 100 newtons oppose it, wouldn’t that just make it go backwards?

if your air resistance force is calculated to be stronger than the original force you’re exerting, you’ve done something wrong.

[quote]…In general, air resistance is proportional to the square of the speed…
[/quote]
Not is the square, as quoted the air resistance is proportional to the square… big difference:)

Bill

Ya. The proportionality factor is normally known as the drag-coefficient ( cd). For most ground vehicles, this is in the range of 0.2 to 0.45. For aircraft, values are around 0.05 to 0.15.

Also note that the values are proportional to the velocity of the object not to the force that is applied by the motor. A vehicle at rest has no air resistance, so that motor force of 10N can be all used to accelerate the vehicle. Once you start getting a decent velocity, then the air resistance force starts to increase, until you get to the point of equilibrium.

thank you all for your help. Il implement it, and il come back with the good news :wink:

darkProphet (or anyone else),

Any update on this? I’m looking to do a similar thing - attempting to model the EDL (entry, descent and landing) of the nasa rover on mars, and so air resistance is crucial in this.

(I’m trying to create a simulation which allows the user to select a custom EDL (when to open the parachute etc) and see the results modelled, very ambitious for a newbie i must admit, but i’m game for trying!)

If you have made any headway with air resistance that would be helpful.

Also Is ODEJava still the best java phyics engine to use in this scenario where most of the forces applied will be through air resistance and drag?

Thanks

well…

I know pretty much what im supposed to do to get air resistance working. But im preoccupied with getting an API neutral physics system for jme at the moment.

What you need to do is approximate a contact constant for the object depending on its width/height/length. Basically, a face to it. Then you need to “map” those values on the different faces… (imaging a 2 dimentional quad, the longer side would obviously have more resistance).

Then when the object is moving, obtain the force by doing something like body.getForce() or something similar (i dont have it infront of me sorry). This will give you a Vector3f and a float. The Vector3f represents the direction of movement the force.

Then you find out which face is facing the direction of movement (you might have to guess sometimes). Then you do this:

float secondForce = faceConstant * drivingForce * drivingForce

body.addForce(secondConstant, new Vector3f(-df.x, -df.y, -df.z));

And you have air resistance. It looks pretty complicated, but its not really. The only complex bit is the approximation and mapping (usually onto a boundingBox, unless its a sphere, then the constant is always the same).

Hope that helps,
DP