These functions and constants are useful for aeronautical computations. The functions categories are:
The aeronautical utility functions and constants are available for import from common/aero/exports.js.
LB_PER_GAL_JETAThe standard weight of Jet-A fuel in pounds per US gallon: 6.7.
LB_PER_GAL_AVGASThe standard weight of aviation gasoline in pounds per US gallon: 6.
STD_ATM_HPAThe standard atmospheric pressure in hectopascals: 1013.25.
STD_ATM_HGThe standard atmospheric pressure in inches of Mercury: 29.92.
STD_TEMP_LAPSEThe standard atmospheric temperature lapse rate in °C/foot: 0.001981.
STD_TRANSITION_ALTThe standard US transition altitude in feet: 18,000.
adjustRocForPower() adjustRocForPower(roc, weight, oldHp, newHp)
Returns an aircraft's rate of climb adjusted for changes in power at the same climb airspeed. The roc, weight, and oldHp arguments are the current rate of climb, aircraft weight and power. The newHp argument is the new power setting.
The computation is adapted from Aerodynamics for Naval Aviators, page 154.
rocweightoldHproc.newHpThe rate of climb in ft/min at newHp.
adjustRocForWeight() adjustRocForWeight(roc, oldWeight, newWeight)
Returns an aircraft's rate of climb adjusted for changes in weight at the same climb airspeed. The roc and oldWeight arguments are the current rate of climb and aircraft weight. The newWeight argument is the new weight to compute the rate of climb for.
The computation is adapted from Aerodynamics for Naval Aviators, page 154.
rocoldWeightroc rate of climb.newWeightThe rate of climb in ft/min at newWeight.
climbGradient() climbGradient(roc, gs)
Returns an aircraft's climb gradient in ft/nm given a rate of climb and ground speed.
rocgsThe climb gradient in ft/nm.
climbGradientToRoc() climbGradientToRoc(aoc, tas)
Returns an aircraft's rate of climb in ft/min given a climb gradient and true airspeed.
aoctasThe rate of climb in ft/min.
createExtendedPtable() createExtendedPtable(table, data)
Creates a new copy of a Ptable with extended data by adding new elements to the end of the original Ptable's a data array. This only extends the data for the first input parameter.
This is often used for gross weight increase options to add new weight data to a table whose first input parameter is weight. This function will not do the right thing if the first parameter is not weight.
For example, if stallIasTable has one parameter, 'weight', and produces a stall airspeed, then:
newStallIasTable = createExtendedPtable(stallIasTable, {p:3000, v:59})
Will create a new Ptable with the data from stallIasTable with a new entry appended at the end of the a data array.
tablePtable to copy and extend.dataa data array intable in the returned Ptable.A Ptable.
createWeightIncrIasPtable() createWeightIncrIasPtable(table, newWeight)
createWeightIncrIasPtable(table, newWeight, newSpeed)
Creates a copy of a weight to airspeed Ptable with extended data. The original table must have one parameter, 'weight', and produce an airspeed output. The copy has an additional entry with newWeight and newSpeed at the end of the data. If newSpeed is omitted, then it is computed from the old maximum weight and the associated airspeed in the last entry of the original table using weightAdjustCas().
For example, if stallIasTable has one parameter, 'weight', and produces a stall airspeed, then the following two statements produce the same result:
newStallIasTable = createExtendedPtable(stallIasTable, {p:3000, v:59})
newStallIasTable = createWeightIncrIasPtable(stallIasTable, 3000, 59)
tablePtable to copy and extend. It must be a table with one input parameter representing weight and the output values must be airspeed.newWeighttable.newSpeedtable.A Ptable.
crosswind() crosswind(angle, windSpeed)
Return the crosswind component given an angle in degrees and a windSpeed. A negative value means the crosswind is coming from the left.
anglewindSpeedThe crosswind component of the wind.
effectiveHeadwind() effectiveHeadwind(windSpeed, windDirection, tas, course)
Returns the "effective headwind": the difference between the tas and the ground speed along the desired course (track). It accounts for the portion of the true airspeed used to crab into the wind to maintain the course.
anglewindSpeedwindDirectiontascourseThe headwind component of the wind.
gasPressureAdjust() gasPressureAdjust(pressure, oldTemp, newTemp)
Compute the new gas pressure at temperature newTemp, for a fixed volume that had pressure at temperature oldTemp. Uses Gay-Lussac's gas pressure law.
This is useful to to adjust oxygen or tire pressure for temperature.
pressureoldTemppressure.newTempThe new gas pressure in pounds per square inch.
glideDistance() glideDistance(glideRatio, cas, hwind, fromAltitude, toAltitude, isa)
Returns the distance to glide dropping from fromAltitude to toAltitude as affected by wind. The glide ratio (glideRatio) for a glide is fixed (i.e., the slope of the glide) so that the distance covered for a given altitude drop remains constant throughout the glide. However, the time for a given altitude drop varies because the TAS changes as altitude drops for a fixed glide cas. To be conservative headwinds are assumed to be steady all the way down and tailwinds are assumed to decrease linearly to zero on the way down.
glideRatiocashwindfromAltitudetoAltitudeisaThe distance covered by the glide in nautical miles.
glideTime() glideTime(glideRatio, cas, fromAltitude, toAltitude, isa)
Returns the glide time in minutes to glide dropping from fromAltitude to toAltitude. The glide ratio (glideRatio) for a glide is fixed (i.e., the slope of the glide), but the time for a given altitude drop varies because the TAS changes as altitude drops for a fixed glide cas.
glideTime() sums the time it takes to drop each 1,000 ft of drop.
glideRatiocasfromAltitudetoAltitudeisaThe glide time in minutes.
headwind() headwind(angle, windSpeed)
Return a the headwind component given an angle in degrees and a windSpeed.
anglewindSpeedThe headwind component of the wind.
takeoffSlopeAdjust() takeoffSlopeAdjust(roll, slope, Vrgs)
Returns a takeoff roll adjusted for slope. The given roll is computed for a flat surface. The function only adjusts for positive slopes because this calculation is not in the POH. Vrgs is the rotation or liftoff ground speed.
rollslopeVrgsThe adjusted takeoff roll in feet.
bankAdjustCas() bankAdjustCas(cas, bank)
Returns an adjusted V-speed in KCAS for a bank angle in degrees. The adjustment applies to airspeeds related to the angle of attack, like stall speeds and operating maneuvering speed.
casbankThe adjusted airspeed in knots.
casToMach() casToMach(cas, pressureAltitude)
Returns an airspeed in Mach given a calibrated airspeed in knots and a pressure altitude.
caspressureAltitudeThe converted airspeed in Mach.
casToTas() casToTas(cas, pressureAltitude, sat)
Returns a true airspeed in knots given a calibrated airspeed in knots, a pressure altitude, and a static air temperature.
caspressureAltitudesatThe converted airspeed in knots.
tasToCas() tasToCas(tas, pressureAltitude, sat)
Returns a calibrated airspeed in knots given a true airspeed in knots, a pressure altitude, and a static air temperature.
taspressureAltitudesatThe converted airspeed in knots.
weightAdjustCas() weightAdjustCas(cas, oldWeight, newWeight)
Returns an adjusted V-speed in KCAS at a given weight for a new weight. The adjustment applies to airspeeds related to the angle of attack, like stall speeds and operating maneuvering speed.
casoldWeightcas airspeed.newWeightThe calibrated airspeed at newWeight.
coldAdjAlt() coldAdjAlt(altitude, arptElevation, arptOat)
Returns a procedure altitude adjusted using the standard cold weather altitude adjustment. When the temperature is below standard conditions, the true altitude will be lower than the indicated altitude. This computes a new indicated altitude that should be used in place of the charted altitude.
altitudearptElevationarptOatThe adjusted altitude MSL in feet.
densityAlt() densityAlt(altitude, altimeter, oat)
Returns the dry density altitude for given altitude, altimeter setting, and OAT. The dry density altitude does not take humidity into account, but it is the reported density altitude in ATIS or ASOS announcement. See Density Altitude.
altitudealtimeteroatThe dry density altitude MSL in feet.
densityAltWet() densityAltWet(altitude, altimeter, oat)
Returns the wet density altitude for given altitude, altimeter setting, OAT, and dew point. The wet density altitude takes humidity into account. See Density Altitude.
altitudealtimeteroatdewPointThe wet density altitude MSL in feet.
indicatedAltitude() indicatedAltitude(pressureAltitude)
indicatedAltitude(pressureAltitude, altimeter)
indicatedAltitude(pressureAltitude, altimeter, transitionAltitude)
Returns the indicated altitude given the pressure altitude, altimeter setting, and transition altitude. Above the transition altitude, the indicated altitude is returned.
pressureAltitudealtimeter (optional)transitionAltitudeThe indicated altitude in feet MSL.
pressureAltitude() pressureAltitude(altitude)
pressureAltitude(altitude, altimeter)
pressureAltitude(altitude, altimeter, transitionAltitude)
Returns the pressure altitude given the indicated altitude, altimeter setting, and transition altitude. Above the transition altitude, the pressure altitude is returned.
altitudealtimeter (optional)transitionAltitudeThe pressure altitude in feet MSL.
stdPressure() stdPressure(altitude)
stdPressure(altitude, altimeter)
Returns the absolute pressure at standard temperature given the altitude and altimeter setting. See Station Pressure.
altitudealtimeter (optional)transitionAltitudeThe pressure altitude in feet MSL.
fmtHeading() fmtHeading(dir)
Return the return a 3-digit heading string from a direction in degrees. For example:
fmtHeading(2.5) === '003'
dirA heading string.
gcBearingTo() gcBearingTo(lat1, long1, lat2, long2)
Return the great circle bearing from an origin (lat1,long1) to a destination (lat2,long2). See Calculate distance, bearing and more between Latitude/Longitude points.
lat1long1lat2long2A heading in degrees from true north. The returned value will be greater than 0 and less than or equal to 360.
gcDistance() gcDistance(lat1, long1, lat2, long2)
Return the great circle distance from an origin (lat1,long1) to a destination (lat2,long2). See Calculate distance, bearing and more between Latitude/Longitude points.
lat1long1lat2long2A distance in nautical miles.
magVar() magVar(lat, long)
magVar(lat, long, altitude)
magVar(lat, long, altitude, date)
Return a numeric magnetic variation given a location, altitude MSL, and date. If no date is provided, the current date is assumed. If no altitude is provided, then 0 MSL is assumed.
Add the magnetic variation to the magnetic heading to get the true heading.
latlongaltitude (optional)date (optional)Date getTime() method). If omitted, the current date is assumed.A magnetic variance in degrees.
magVarFromString() magVarFromString(magVarStr)
Return a numeric magnetic variation from a magnetic variation string. For example:
magVarFromString('14W') === -14
Add the magnetic variation to the magnetic heading to get the true heading.
magVarStr/(\d{1,3})([EW])/. The numeric portion must be less than or equal to 180.A magnetic variance in degrees.
magVarToString() magVarToString(magVar)
Return a magnetic variation string given a numeric magnetic variation. A negative magVar is west. For example:
magVarFromString(-14) === '14W'
magVarA magnetic variance string of the form /(\d{1,3})([EW])/.
runwayIdToDir() runwayIdToDir(id)
Return the magnetic runway direction from the runway ID. This strips the [LRC] from the end and multiplies by 10.
idA Number representing the magnetic heading in degrees.
export function runwayRecip (id) {
runwayRecip() runwayRecip(id)
Return the reciprocal runway identifier string given the base identifier. Esentially this flips the base ID 180 degrees and flips any L or R designation.
idA runway ID string for the reciprocal runway
iatToSat() iatToSat(iat, tas)
Returns the static air temperature (SAT or OAT) given the indicated outside air temperature and the true airspeed. iatToSat() computes the increase in temperature measured at the outside temperature probe due to airspeed and subtracts that from the indicated temperature.
iattasThe static air temperature (SAT or OAT) in degrees Celsius.
ramRise() ramRise(tas)
Returns the ram rise: the increase in temperature measured at the outside temperature probe due to airspeed.
tasThe ram rise in degrees Celsius.
satToIat() satToIat(sat, tas)
Returns the indicated outside air temperature given the static air temperature (SAT or OAT) and the true airspeed. iatToSat() computes the increase in temperature measured at the outside temperature probe due to airspeed and adds that to the static temperature.
sattasThe indicated air temperature (SAT or OAT) in degrees Celsius.
stdTemp() stdTemp(pressureAltitude)
Returns the standard temperature at a pressure altitude.
pressureAltitudeThe standard air temperature in degrees Celsius.
stdTempDiff() stdTempDiff(pressureAltitude, oat)
Returns the ISA temperature difference: the difference between the standard temperature at a pressure altitude and the outside air temperature.
pressureAltitudeoatThe standard air temperature difference in degrees Celsius.
tempDiffCtoF() tempDiffCtoF(c)
Returns the ISA temperature difference in Fahrenheit given an ISA temperature difference in degrees Celsius.
cThe standard air temperature difference in degrees Fahrenheit.
export function tempDiffFtoC (f) {
tempDiffFtoC() tempDiffFtoC(f)
Returns the ISA temperature difference in degrees Celsius given an ISA temperature difference in Fahrenheit.
fThe standard air temperature difference in degrees Celsius.
fmtSerialNum()acType.fmtSerialNum()
acType.fmtSerialNum(serialNum)
acType.fmtSerialNum(serialNum, modelInfo)
This function returns a formatted version of an aircraft serial number, specified by serialNum, according to the parameters in modelInfo. If modelInfo has a serialFixedWidth property, then a serial number that is less than the required width, not including the prefix, will be extended with leading zeroes. If modelInfo has a serialPrefix property, then the serialPrefix is prepended to the (extended) serial number.
If modelData is omitted, then the current aircraft (acData) is used. If serialNum is omitted then the current serial number (acData.serialNumber) is used.
serialNummodelInfoserialPrefix and serialFixedWidth properties.A full serial number string of proper width, and includes the serial number prefix.
fmtSerialNum()acType.fmtSerialNum()
acType.fmtSerialNum(modelInfo)
This function returns a formatted version of the serial number range in modelInfo.serialNumbers. If modelInfo is omitted, then the current aircraft (acData) is used. The returned string converts the serial number range into a human-readable format. If modelInfo.serialFixedWidth is specified, then leading zeros are prepended to the serial number to make it the required width. Any prefix specified by modelInfo.serialPrefix is also prepended to each serial number.
For example, the serial number range string: 512-1024 with a fixed width of 5 and a prefix of '172' will be converted to "17200512 thru 17201024", and '1025-' will be converted to "17201025 and up".
modelInfoserialNumbers property and may contain serialPrefix and serialFixedWidth properties.A string with a human-readable version of a serial number range string.