Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Hybrid666

simulating changing wind speed and direction

This topic is 5652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im wanting to realisticly simulate an anemometer (wind measuring device ) in c++ but am having trouble!! am looking for something that stores wind speed and direction in 2 floats, or even better a vector (using a bit of trig ) i need a realstic simulation of the wind, sort of like the stuff u see in a good golf game, and am wondering if anyone can help me with it? att he moment im using a feedback loop that alters the speed and direction using a Gust() function randomly at random times, and the wind direction always osscilates using a sine wave for variation, but this is messy i know! and a little buggy thanks in advance, im desperatly in need of someone who knows whatthey''re talking about! :D

Share this post


Link to post
Share on other sites
Advertisement
A vector is ideal for solving that problem. You would need to explain what your input data is in order to get a meaningful answer to your question though.

Share this post


Link to post
Share on other sites
i know i want to use a vector, im interested in how to realisticly simulate the changes to that vector, via realistic simulation of an anemometer

Share this post


Link to post
Share on other sites
I have no idea what you mean with anemometer. But if you want to simulate wind, you first need to make an important decision: wether you 1.) simulate the wind with a single vector, assumning the wind to be equal in all points in the air or 2.) you simulate wind direction uniquely in every point in space. Let''s discuss these.

1.) Assuming the wind is equal in all points in space. First make a generator that generates a random wind vector (with varying magnitude and direction). Then you can simulate the wind like this:

Vector wind = GenerateRandomWind();
while( !game_over )
{
Vector dWind = GenerateRandomWind();
float alpha = 0.1;
wind = wind*(1-alpha) + dWind*alpha;
}

I hope you understand what I mean.

2.) Real simulation of wind. One option is to divide the space you''re simulating into a grid of small voxels and assign a wind vector to each voxel. Then you can use the Navier-Stokes equations to simulate the wind. But in practice this is out of option because it takes from minutes to hours to compute a single frame (if you want it to be realistic).

- Mikko Kauppila

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
this is my thoery, and here is the equations for wind ressistance

Fdrag = 0.5 * Cd * A * rho * v2

where Cd = coefficient of friction
A is frontal area of car
rho (Greek symbol )= density of air
v = speed of the car


my theory involves finding the area of the car facing the wind, i will do this by creating a siloutte in a stencil buffer like kinda way, density of air is 1.29 kg/m3 (0.0801 lb-mass/ft3), the coefficcient is what you will tweek, the frontal coefficient of a corvertte is aproximately .3 and teh velocity will be the velocity of teh wind - car so if hte car is not moving, and the wind is at 3,0,0 the velocity is 3, if the car is moving at 1,0,0 and the wind is goin at 3,0,0 the wind speed is 2, then add a force (hopefully you physics engine can do this) to teh bodies in teh dirrectoin of the wind at teh strength of fdrag

all of the equation stuff is coming from http://home.planet.nl/~monstrous/tutcar.html

[grhodes_at_work corrected equation to make the "2" following "v" to be a superscript]


[edited by - grhodes_at_work on April 3, 2003 10:08:26 PM]

Share this post


Link to post
Share on other sites
cool, i see what you''re getting at. im definitly going with option 1 at the mo, cos i want wind to b a simple vector in space.

at the mo i create a VECTOR3D wind(0, 0, 0);

then i vary the float ''angle'' randomly through a slightly deviating sine wave so it ''wobbles''. i also vary speed by adding/subtracting a random nubmer to it each frame, so it is inconsistant

next i create a ''gust'' every 1-10 seconds which greatly alters both speed and direction, and swings the direction round to a new angle (0-360) over a period of 10-20 frames, and alters the speed immediatly.

finally using a bit of trig i convert my flaot angle, and float speed into a 3D vector.

what you think?

Share this post


Link to post
Share on other sites
sorry car guy - i have no car - only masses in 3d space, which are points.

but i see what you''re saying - however im looking at creating the wind vector realistically each frame, i can deal with the effect wind has upon masses using my physics engine.

i want to simulate the actual wind itself, not how it affects objects. this essentially means create an anemometer type thing ( imagine the cockerel thing with north south east & west on it above a farm barn spinnign around... thats kinda an anemometer )

iwant algorithms to alter the wind realisitcly, in both speed and direction, and convert these values into a vector. ( unlesss there is a bettter method )


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ah well, im a moron, and i now see your guestion, why not get a random gust dirrection and speed and add it to your vector, and everyframe you also slow the wind down X ammount so like if the wind is 1,0,0, and u add 2,1,0 to it u get 3,1,0 but everyframe u also devie the wind in half so u really get 1.5, .5, 0 as your new wind so if the random gust function gives u 0,0,0 then u add nothing and the wind slows down .75, .25, 0 , i dunno, if you just get a random new direction and instantly apply it you could go from 1,0,0 wind to -1,0,0 wind whcihc would be very unrealistic, so mayeb you could interpolate the gust fucntion into you current posstion and call gust every 2 seconds, gust(-1,0,0) t = 0 -> 1,0,0 t = 1000 - > 0,0,0 t= 2000 - > -1,0,0 or if you did rotations instead of vectors u could do t= 0 -> 1,0,0 t=1000 -> 0,1,0 t=2000 -1,0,0

hope that helped any

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
sorry that last vector is -1,0,0

Share this post


Link to post
Share on other sites
Just a note to say that Anonymous Poster''s theory/FDrag equation is not actually his theory. This equation comes directly from classical aerodynamic theory observed in wind tunnels and developed over the past 100 years. It is an approximate equation for drag.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!