Implementing air drag

Hi all,

I am currently trying to implement air drag to enable an aircraft to fly a curve instead of drifting into one direction. My first idea was to cast several rays at the object (the aircraft), which are opposite to the direction of the object’s moving direction. From the number of rays intersecting the object, I could calculate a value for the air drag to be applied. This would just be a force opposite to the object’s moving direction. However, this would involve calculating a lot of collisions, which would have a great impact on performance, wouldn’t it? Does anyone have a better idea to solve this problem?

yea don’t do that.

You basically want surface area, so you can either hard-code the value, or calculate it at startup. Or you can estimate it by taking the surface area of the bounding box. The force would just be that area multiplied by the velocity, and will always be the negative direction of the velocity.

Yes, but wouldn’t I need the area that is perpendicular to the current flying direction? I don’t really know how to calculate it because I got rotations in three dimensions.

you can calculate the surface area on the front, sides, and top/bottom, and then just multiply them by the velocity vector. So when flying straight forward 100% of the forward surface area will affect the velocity backwards. But when turning, some of the bottom will be exposed; so when multiplying that rotation by the velocity you will get a slightly different force: a combination of the front area and the bottom area. That should simulate enough of what you are looking for.

Can’t you do something simple with the angle diff between object speed and orientation? angle=0 => minimal drag; angle=PI/2 => maximal drag.

You can also use angle diff with the up/left vector of the object orientation.

What cghisali said will work fine and will be easy to implement, and probably a great place to start. If it ends up not being as precise as you want, you can build up from there later.

Okay, I think I will try that, thank you.