Added speed of sound calculation:

* Influences the advanced ballistics transonic instability
* Influences the ATragMX range card output
This commit is contained in:
ulteq 2015-05-29 11:36:37 +02:00
parent e2970ab40e
commit abf0149b1d
4 changed files with 24 additions and 3 deletions

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
private ["_range", "_elevation", "_windage1", "_windage2", "_clickSize", "_clickNumber", "_clickInterval", "_lead", "_TOF", "_velocity", "_kineticEnergy", "_rangeOutput", "_elevationOutput", "_windageOutput", "_lastColumnOutput"];
private ["_range", "_elevation", "_windage1", "_windage2", "_clickSize", "_clickNumber", "_clickInterval", "_lead", "_TOF", "_velocity", "_kineticEnergy", "_rangeOutput", "_elevationOutput", "_windageOutput", "_lastColumnOutput", "_speedOfSound"];
_lastColumnOutput = "";
if (GVAR(showWind2) && GVAR(rangeCardCurrentColumn) == 0) then {
@ -32,6 +32,8 @@ if (GVAR(currentUnit) == 1) then {
lnbClear 5007;
_speedOfSound = GVAR(temperature) call EFUNC(weather,calculateSpeedOfSound);
{
_range = _x select 0;
_elevation = _x select 1;
@ -72,7 +74,7 @@ lnbClear 5007;
_windageOutput = Str(Round(_windage1 * 100) / 100);
_rangeOutput = Str(_range);
if (_velocity < 340.29) then {
if (_velocity < _speedOfSound) then {
_rangeOutput = _rangeOutput + "*";
};

View File

@ -8,6 +8,7 @@ PREP(calculateBarometricPressure);
PREP(calculateDewPoint);
PREP(calculateHeatIndex);
PREP(calculateRoughnessLength);
PREP(calculateSpeedOfSound);
PREP(calculateTemperatureAtHeight);
PREP(calculateWetBulb);
PREP(calculateWindChill);

View File

@ -0,0 +1,17 @@
/*
* Author: Ruthberg
*
* Calculates the speed of sound for a given temperature
*
* Arguments:
* temperature - degrees celcius <NUMBER>
*
* Return Value:
* speed of sound - m/s <NUMBER>
*
* Return value:
* None
*/
#include "script_component.hpp"
(331.3 + (0.6 * _this))

View File

@ -577,7 +577,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
positionOffset[0] += sin(bulletDir + M_PI / 2) * spinDriftPartial;
positionOffset[1] += cos(bulletDir + M_PI / 2) * spinDriftPartial;
if (bulletSpeed < 345 && bulletSpeedAvg > 340 && bulletSpeed > 335) {
float speedOfSound = 331.3 + (0.6 * temperature);
if (bulletSpeed < (speedOfSound + 5) && bulletSpeedAvg > speedOfSound && bulletSpeed > (speedOfSound - 5)) {
std::uniform_real_distribution<double> distribution(0.0, 1.0);
double coef = 1.0f - bulletDatabase[index].transonicStabilityCoef;