Jump to content


- - - - -

How to simulate wind?


5 replies to this topic

#1 MarekKnows.com

    Valued Member

  • Members
  • PipPipPip
  • 190 posts
  • LocationOntario, Canada

Posted 13 December 2005 - 01:35 PM

I've created some objects that have the following attributes:

a = acceleration
v = velocity
p = position
t = delta time

Right now, I am doing the following:
v += (a + gravity) * t;
p += v * t;

How do I incorporate wind? Lets say that I have a wind velocity = w. where would I put it in my equations?

I was thinking of doing this:
v += (a + gravity + w) * t;

but I don't think this is right, because wind is not an acceleration.... it is a velocity.

So then I was thinking maybe:
v += (a + gravity) * t + w;

but because t is not constant then w does not change the velocity in a nice fasion.

What is the correct way to handle wind speed?
C++, 3D OpenGL and Game Programming video tutorials:
www.MarekKnows.com
Play my free games: Ghost Toast, Zing

#2 roel

    Senior Member

  • Members
  • PipPipPipPip
  • 698 posts

Posted 13 December 2005 - 01:46 PM

you can treat wind as a force, like gravity.

#3 zavie

    Member

  • Members
  • PipPip
  • 91 posts

Posted 13 December 2005 - 01:48 PM

Quick and dirty way: just add wind's velocity.

More realistic way: compute the surface the object is offering to the wind (a simple square, or maybe a real projection), and estimate the force resulting from the wind pushing this surface considering the wind as a pressure (F=PS if I recall correct). Then F=ma :-) The real problem is to get a nice P=f(Vwind) function.

Physically based way: implement some Ph.D thesis about fluid dynamics. ;-)

#4 kariem2k

    Valued Member

  • Members
  • PipPipPip
  • 207 posts

Posted 13 December 2005 - 03:10 PM

yes treat it as a force not a velocity

also treat the gravity as a force not acceleration and treat them as vectors not scalar values.

#5 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 13 December 2005 - 03:18 PM

Wind in itself is not a force, it just the velocity of air particles. What pushes your object is friction, which is relative to the wind's velocity. If your object is moving along the direction of the wind, but slower, the wind makes your object moving faster. But if your object is moving faster than the wind, things are reversed: air resistance causes your object to slow down up until it has the same velocity as the wind.

So what you should do is incorporate air friction in your calculations. Calculate the relative wind direction by subtracting your object's velocity from the wind velocity. This is the direction of the force, which you should multiply by a constant which describes how much air friction influinces your object. Divide this vector by the mass of the object to get the acceleration (F=m*a => a=F/m)
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#6 opcode-foo

    New Member

  • Members
  • PipPip
  • 17 posts

Posted 21 December 2005 - 10:27 PM

mmakrzem said:

I've created some objects that have the following attributes:

a = acceleration
v = velocity
p = position
t = delta time

Right now, I am doing the following:
v += (a + gravity) * t;
p += v * t;

How do I incorporate wind? Lets say that I have a wind velocity = w. where would I put it in my equations?

I was thinking of doing this:
v += (a + gravity + w) * t;

but I don't think this is right, because wind is not an acceleration.... it is a velocity.

So then I was thinking maybe:
v += (a + gravity) * t + w;

but because t is not constant then w does not change the velocity in a nice fasion.

What is the correct way to handle wind speed?

Well, for starters, your equations are just the simple kinematic equations, so no rigid body involved here. So, a wind you could treat just like a force applied from some direction. It would be a bit more involved in rigid body sim, but you would simplify and treat wind as a resistance force or just a directional force. Simulating it like a fluid mechanics problem would be ... overkill ;-) In a car racing sim, you would model wind resistance, but treat it mostly uniform like a frictional force, and maybe a little more involvement, but you really don't need much more complex modelling like this for a game, it will be realistic enough to believe it. Last, to get a more 'windy' feel, you could randomly perturb the wind force amount at times, like from hard to mild, none to tornado blast, etc.... just modulate the amount of pressure force the wind is putting on the object.

[EDIT]
Let me clarify by force, it would just become a velocity on the object, disregarding mass since it's a particle you wind up

x = x0 + (v+wind_vx)*t
y = y0 + (v+wind_vy)*t - 0.5*g*t*t


And wind is a velocity in some direction. I just ignore the mass of the particle so the force ends up being a linear accel which than becomes
a constant applied to velocity .... but, that is not very rigorous, but it *works* in a video game sim.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users