@squawk/flight-math

Aviation flight computer calculations - the programmatic equivalent of an E6B flight computer. Pure functions for wind triangles, altitude corrections, airspeed conversions, and more.
Documentation
Part of the @squawk aviation library suite. See all packages on npm.
Installation
npm install @squawk/flight-math
Usage
All exports are organized by domain namespace, following the same pattern as @squawk/units:
import { atmosphere, airspeed, wind } from '@squawk/flight-math';
const da = atmosphere.densityAltitude(5000, 29.92, 35);
const ta = atmosphere.trueAltitude(10000, 29.85, -10);
const cas = airspeed.calibratedAirspeedFromTrueAirspeed(250, 20000);
const wt = wind.solveWindTriangle(150, 270, 310, 25);
const hw = wind.headwindCrosswind(310, 15, 280);
const xw = wind.crosswindComponent(310, 15, 280);
const w = wind.findWind(135, 150, 275, 270);
Relationship to @squawk/units
This package complements @squawk/units, which provides unit conversions, formatting, and the ISA standard atmosphere model. @squawk/flight-math provides higher-level computations that combine multiple inputs (wind triangles, density altitude from field observations, etc.) and uses @squawk/units internally.
Functions that already exist in @squawk/units are not re-exported. Import them directly:
| Pressure altitude from indicated alt + QNH | @squawk/units (pressure.pressureAltitudeFt) |
| Density altitude from PA + OAT | @squawk/units (isa.densityAltitudeFt) |
| TAS from CAS | @squawk/units (isa.trueAirspeedFromCalibratedKt) |
| Mach from TAS | @squawk/units (isa.machFromTrueAirspeedKt) |
| TAS from Mach | @squawk/units (isa.trueAirspeedFromMachKt) |
| Density altitude from field observations | @squawk/flight-math (atmosphere.densityAltitude) |
| True altitude correction | @squawk/flight-math (atmosphere.trueAltitude) |
| CAS from TAS | @squawk/flight-math (airspeed.calibratedAirspeedFromTrueAirspeed) |
| Wind triangle / components | @squawk/flight-math (wind.*) |
Namespaces
- atmosphere - Altitude calculations combining multiple field inputs
- airspeed - Airspeed conversions not covered by
@squawk/units
- wind - E6B wind triangle, headwind/crosswind components, reverse wind triangle
- descent - Top of descent, required descent/climb rate, gradient conversions, VDP
- navigation - Holding pattern entry, DME arc lead, 1-in-60 rule
- turn - Standard rate bank angle, turn radius, time to turn, load factor
- glide - Glide distance with and without wind correction
- pivotal - Pivotal altitude for ground reference maneuvers
- solar - Sunrise/sunset, civil twilight, day/night determination (NOAA algorithm)
- magnetic - Magnetic declination and field components (WMM2025), true/magnetic bearing conversion
- planning - Fuel required, endurance, point of no return, equal time point