Hey klem
Sorry this reply took so long.. I have been busy with some of my own stuff..
On that note I still have not writen the C# code for you yet, but wanted to share with you my matlab code, i.e.
Code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ISA Standard
Alt_Tropopause_m = 11000.0; % ISA Altitude of Tropopause in meters
Tmp_Tropopause_K = 216.65; % ISA Temperature of Tropopause in Kelvin
To_K = 288.15; % ISA Temperature @ SL in Kelvin [288.15(°K) = 15(°C) = 59(°F)]
Po_mB = 1013.25; % ISA Pressure @ SL in millibar [1013.250(mB) = 29.92126("Hg) = 101325.0(Pa) = 2116.2166(lbs/ft^2) = 760.0(mmHg) = 14.69595(psi) = 1.0(atm)]
Po_Hg = 29.92126; % ISA Pressure @ SL in inch of mercury [1013.250(mB) = 29.92126("Hg) = 101325.0(Pa) = 2116.2166(lbs/ft^2) = 760.0(mmHg) = 14.69595(psi) = 1.0(atm)]
TLR_Cpm = 0.0019812; % ISA Temperature Lapse Rate in Celsius/meter [6.5(°C)/1,000(m) = 1.9812(°C)/1,000(ft)]
TLR_Kpm = 0.0019812; % ISA Temperature Lapse Rate in Celsius/meter [6.5(°K)/1,000(m) = 1.9812(°K)/1,000(ft)]
PLR_ftpHg = 1000; % ISA Pressure Lapse Rate in feet/inch of mercury [1,000ft/"Hg]
% Where
% 29.92000 "Hg = 1013.207489 millibar
% 29.92126 "Hg = 1013.250158 millibar
if (units_si == 1)
To = To_K;
Po = Po_mB;
PLR = 1;
TLR = TLR_Cpm;
else
Po = Po_Hg;
To = To_K;
PLR = PLR_ftpHg;
TLR = TLR_Cpm;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP 1) Find the PRESSURE DIFFERENCE
%
% Pdif = Po - Altimeter_Set
Pdif = Po - Altimeter_Set;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP 2) Find the ALTITUDE CORRECTION due to the PRESSURE DIFFERENCE @ SL
%
% Alt_pcorr = (To/TLR) × [1 - (Altimeter_Set/Po)^0.190261]
%
% Or you can use the following simple approximation
%
% Alt_pcorr = Pdif × PLR
%
% Where:
% Altimeter_Set = Is the altimeter set/offset (CoD: Altimeter Pinion)
Alt_pcorr = (To./TLR) .* (1 - power((Altimeter_Set./Po),0.190261));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP 3) Find the PRESSURE ALTITUDE due to the ALTITUDE CORRECTION
%
% Alt_pressure = Alt_ind + Alt_pcorr
%
% Where:
% Alt_ind = The Indicated Altitude
% To/TLR = 44330.77(m) = 145442.15(ft)
Alt_pressure = Alt_indicated + Alt_pcorr;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP 4) Find STANDARD TEMPERATURE due to the TEMPERATURE DIFFERENCE @ SL
%
% Tstd = To - TLR × Alt_pressure
%
% Tstd = 15(°C) - 0.0019812(°C/ft) × 8,000(ft)
% Tstd = 15(°C) - 15.8496(°C)
% Tstd = -0.8496(°C) = 272.30(°K)
%
% or in Kelvin
%
% Tstd = 288.15(°K) - 0.0019812(°K/ft) × 8,000(ft)
% Tstd = 288.15(°K) - 15.8496(°C)
% Tstd = 272.30(°K)
Tstd = To - TLR .* Alt_pressure;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP 5) Find DENSITY ALTITUDE
%
% NOTE: TLR, Tstd, and OAT must be in units of Kelvin for this formula to work!!
%
% Alt_denisty = Alt_pressure + (Tstd/TLR) × [1 - (Tstd/OAT)^0.2349690]
Alt_density = Alt_pressure + (Tstd. / TLR) .* (1 - power((Tstd ./ Temp_indicated),0.2349690));
I you have not used matlab, know that it does some things under the hood. The big thing being arrays, if you have an array, and you want to do stuff with it, you don't have to do the indexing for example, say we have an array called 'dog' that I want to apply an offset to, and create a new array called 'cat'. In matlab all you have to do is the following:
Where as in most other languages you would have to do the indexing yourself, i.e.
Code:
for (ii=0; ii<dog.Lenght-1;ii++)
{
cat(ii) = dog(ii) + 100;
}
Same goes for mul or div
Code:
cat = dog .* 100;
cat = dog ./ 100;
The period before the * and / means apply this to each value (each index), instead of the sum of the array
Feel free to contact me if you have any questions
PS still debating on wether we can use the ingame temp, or not, ill keep you posted