mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Migrate pressure to a typed unit.
This commit is contained in:
@@ -16,6 +16,9 @@ KPH_TO_KNOTS = 1 / KNOTS_TO_KPH
|
||||
MS_TO_KPH = 3.6
|
||||
KPH_TO_MS = 1 / MS_TO_KPH
|
||||
|
||||
INHG_TO_HPA = 33.86389
|
||||
INHG_TR_MMHG = 25.400002776728
|
||||
|
||||
|
||||
def heading_sum(h: int, a: int) -> int:
|
||||
h += a
|
||||
@@ -181,6 +184,27 @@ def mach(value: float, altitude: Distance) -> Speed:
|
||||
SPEED_OF_SOUND_AT_SEA_LEVEL = knots(661.5)
|
||||
|
||||
|
||||
@dataclass(frozen=True, order=True)
|
||||
class Pressure:
|
||||
pressure_in_inches_hg: float
|
||||
|
||||
@property
|
||||
def inches_hg(self) -> float:
|
||||
return self.pressure_in_inches_hg
|
||||
|
||||
@property
|
||||
def mm_hg(self) -> float:
|
||||
return self.pressure_in_inches_hg * INHG_TR_MMHG
|
||||
|
||||
@property
|
||||
def hecto_pascals(self) -> float:
|
||||
return self.pressure_in_inches_hg * INHG_TO_HPA
|
||||
|
||||
|
||||
def inches_hg(value: float) -> Pressure:
|
||||
return Pressure(value)
|
||||
|
||||
|
||||
def pairwise(iterable: Iterable[Any]) -> Iterable[tuple[Any, Any]]:
|
||||
"""
|
||||
itertools recipe
|
||||
|
||||
Reference in New Issue
Block a user