Jump to content
Sign in to follow this  
dmarkwick

Need formula - wind direction

Recommended Posts

A while back people were very helpful in suggesting ways for me to get wind strength, which turned out to look like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_WindStrength = (SQRT((wind select 0)^2 + (wind select 1)^2));

Now, for two rather cool micro-projects, I need to know the wind direction too.

Can any maths gurus suggest a formula for getting wind direction? I suggest using wind select 0 and wind select 1 as I only need lateral direction. They will give you a positive or negative number depending on wind direction and speed, which should give you a vector from which a direction should be got, using some sort of trigonometry witchcraft I expect wink_o.gifsmile_o.gif

Share this post


Link to post
Share on other sites

I was wrong, doesn't work out quite the same, interesting though, appears to have a slight updraft if this read vaguely the same.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_fVectorLength =

{

sqrt( ((_this select 0)^2)+((_this select 1)^2)+((_this select 2)^2) )

};

_fVectorDotProduct =

{

private["_v1","_v2"];

_v1=_this select 0;

_v2=_this select 1;

(_v1 select 0)*(_v2 select 0) + (_v1 select 1)*(_v2 select 1) + (_v1 select 2)*(_v2 select 2)

};

_fVectorAngle =

{

private["_v1","_v2","_v1l","_v2l"];

_v1=_this select 0;

_v2=_this select 1;

_v1l=_v1 call _fVectorLength;

_v2l=_v2 call _fVectorLength;

acos(([_v1,_v2] call _fVectorDotProduct)/(_v1l*_v2l))

};

_wind2D = [wind select 0, wind select 1, 0];

_angle = [_wind2D,[0,1,0]] call _fVectorAngle;

_windDir = if((_wind2D select 0) < 0)then{360 - _angle}else{_angle};

Share this post


Link to post
Share on other sites

A bit easier...<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_wind = wind;

hint ("Wind dir: " + str ((_wind select 0) atan2 (_wind select 1)))

Share this post


Link to post
Share on other sites

... and with full 360° ...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_wind = wind;

hint str((((_wind select 0) atan2 (_wind select 1)) + 360) mod 360);

Share this post


Link to post
Share on other sites

Hmm very interesting. This script only shows the wind strength, right? Is it possible to influence the wind strength depending on meteological data? I had the idea of influencing the behaviour of air vehicles during a huge storm and connecting it with mission.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×