Home   Help Search Login Register  

Author Topic: Getting wind direction and wind speed  (Read 1585 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Getting wind direction and wind speed
« on: 08 Oct 2007, 01:18:22 »
Hi

I'm trying to make a simple weather report script (showing actual weather and an average forecast, really really simple) and i run into troubles to get wind direction and speed. I know that the command "wind" does return a vector but as a complete idiot in maths, i don't know how to treat these values to get a wind direction and a wind speed.

If someone could help me out at this point, it would be great.


Myke out

P.S.
Looked at seven's sniper/spotter script but he's using particle to determine wind data. I like to use the wind command.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Getting wind direction and wind speed
« Reply #1 on: 08 Oct 2007, 12:18:36 »
Direction of the wind (-180 to +180 from North):
Code: [Select]
_windDirInDegrees = (wind select 0) atan2 (wind select 1);

Direction of the wind (0 to 360 from North):
Code: [Select]
_windDirInDegrees = (((wind select 0) atan2 (wind select 1)) + 360) mod 360;

For the wind speed:
Code: [Select]
_windSpeedInMetresPerSecond = sqrt (((wind select 0) ^ 2) + ((wind select 1) ^ 2) + ((wind select 2) ^ 2));
_windSpeedInKilometersPerHour = _windSpeedInMetresPerSecond * 3.6;

I think the particle method of determining wind pre-dates the wind command, so just use the command.
« Last Edit: 08 Oct 2007, 12:20:29 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Getting wind direction and wind speed
« Reply #2 on: 09 Oct 2007, 00:47:28 »
thx Spooner

i can be arsed with these math, great work!


Myke out

:EDITH:
Works like a charm. Solved and closed.
« Last Edit: 09 Oct 2007, 02:01:07 by myke13021 »