2015-04-07 19:46:43 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
*
|
|
|
|
* Calculates the true wind speed at a given world position
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: _this - world position <posASL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2015-04-07 19:54:29 +00:00
|
|
|
* 0: wind speed - m/s <NUMBER>
|
2015-04-07 19:46:43 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-04-05 19:08:55 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_windSpeed", "_windDir", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"];
|
|
|
|
|
|
|
|
fnc_polar2vect = {
|
2015-04-07 19:27:04 +00:00
|
|
|
private ["_mag2D"];
|
|
|
|
_mag2D = (_this select 0) * cos((_this select 2));
|
|
|
|
[_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))];
|
2015-04-05 19:08:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_windSpeed = vectorMagnitude ACE_wind;
|
|
|
|
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
|
|
|
|
|
|
|
|
// Wind gradient
|
|
|
|
if (_windSpeed > 0.05) then {
|
2015-04-07 19:27:04 +00:00
|
|
|
_height = (ASLToATL _this) select 2;
|
|
|
|
_height = 0 max _height min 20;
|
|
|
|
if (_height < 20) then {
|
|
|
|
_roughnessLength = _this call FUNC(calculateRoughnessLength);
|
|
|
|
_windSpeed = _windSpeed * ln(_height / _roughnessLength) / ln(20 / _roughnessLength);
|
|
|
|
};
|
2015-04-05 19:08:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Terrain effect on wind
|
|
|
|
if (_windSpeed > 0.05) then {
|
2015-04-07 19:27:04 +00:00
|
|
|
_newWindSpeed = 0;
|
|
|
|
{
|
|
|
|
_windSource = [100, _windDir + 180, _x] call fnc_polar2vect;
|
|
|
|
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
|
|
|
|
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
|
|
|
};
|
|
|
|
_windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect;
|
|
|
|
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
|
|
|
|
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
|
|
|
};
|
|
|
|
_windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect;
|
|
|
|
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
|
|
|
|
_newWindSpeed = cos(_x * 9) * _windSpeed;
|
|
|
|
};
|
|
|
|
} forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
|
|
_windSpeed = _newWindSpeed;
|
2015-04-05 19:08:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Obstacle effect on wind
|
|
|
|
if (_windSpeed > 0.05) then {
|
2015-04-07 19:27:04 +00:00
|
|
|
_newWindSpeed = 0;
|
|
|
|
{
|
|
|
|
_windSource = [20, _windDir + 180, _x] call fnc_polar2vect;
|
|
|
|
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
|
|
|
|
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
|
|
|
};
|
|
|
|
_windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect;
|
|
|
|
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
|
|
|
|
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
|
|
|
};
|
|
|
|
_windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect;
|
|
|
|
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
|
|
|
|
_newWindSpeed = cos(_x * 2) * _windSpeed;
|
|
|
|
};
|
|
|
|
} forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
|
|
|
|
_windSpeed = _newWindSpeed;
|
2015-04-05 19:08:55 +00:00
|
|
|
};
|
|
|
|
_windSpeed = 0 max _windSpeed;
|
|
|
|
|
|
|
|
_windSpeed
|