Wind resistance.

Blitz3D Forums/Blitz3D Programming/Wind resistance.

poopla(Posted 2003) [#1]
Ive been looking all over today(when I can at school) but hav'nt been able to find the "proper" equation for wind resistance, or at least on that will work well in code. Any help is appreciated.


WolRon(Posted 2003) [#2]
Most formulas are somewhat specific in their use. If you are just looking for something general then you can probably just hack up something yourself that does the job.

If you know specifically what you are trying to achieve, perhaps I can find you something in my Physics book at home.


sswift(Posted 2003) [#3]
To calculate air friction, you must convert your movement vector into a magnitude, (speed) and a direction normal.


You then apply air friction like so:


Const UNITS_PER_METER# = 1.0
Const GRAVITY# = 9.8 * UNITS_PER_METER#
Const AIR_FRICTION_CONSTANT# = 0.005

Air_Friction_Force# = AIR_FRICTION_CONSTANT# * ThisPlayer\Speed#^2.0

ThisPlayer\Speed# = ThisPlayer\Speed# - (Air_Friction_Force# * Time_Delta_Sec#)


Time_Delta_Sec# is the fractional seconds which elapsed last frame. So if the last frame lasted 100 milliseconds, then it would be 0.1.

Speed# is in units per second, which conveiently for me is also meters per second, because I use a scale of 1 unit = one meter.


Note that air friction is expoential. Your vehicle will increase to a certain speed quickly, begin to slow it's acceleration, and reach a constant speed. Then when you let off the gas, you will slow down quickly, but coast along for what seems like forever at a lower rate of speed.

This is kind of sucky for games, so even in my hover racing game, I ALSO simulate ground friction even though the vehicle does not touch the ground. Ground friction will not stop the vehicle from accelerating forever, but when the vehicle slows down it takes over and makes it quickly screech to a halt.

So the two can compliment eachother. But if you're making an airplane sim, then all you want really is air friction.

Here is ground friction in case you want it:

; Compute the effect of land friction. Land friction is not dependent on speed.
ThisPlayer\Speed# = ThisPlayer\Speed# - (2.0 * Time_Delta_Sec#)


Add new thrust each frame AFTER computing the friction's effect on the vector from the previous frame.


sswift(Posted 2003) [#4]
Btw, that 2.0 in the second equation is the ground fricton constant. It is the speed at which the object slows down. In this case, 2 meters per second in speed will be lost each second. Reduce that to reduce the friction. It must be less than your forward thrust or you won't move at all.


DarkEagle(Posted 2003) [#5]
if you dont need it too accurate and you want different air friction in different directions, try this:

for a sail, where the x air resitance is very high, you would do this:
;relative friction
rXfriction# = 0.2
rYfriction# = 0.99
rZfriction# = 0.99

;loop
;entity is your sail, which gets rotated
tformvector rXfriction#,rYfriction#,rZfriction#,entity,0
wXfriction# = tformedx()
wYfriction# = tformedy()
wZfriction# = tformedz()

wXvel# = wXvel# * wXfriction#
wYvel# = wYvel# * wYfriction#
wZvel# = wZvel# * wZfriction#


variables prefixed with "r" are relative to the object, and those with "w" are world...


poopla(Posted 2003) [#6]
Thanks sswift, that looks like the ticket :). Thanks everyone else too.