diff options
Diffstat (limited to 'src/deco.c')
-rw-r--r-- | src/deco.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -9,6 +9,7 @@ #define RND(x) (round((x) *10000) / 10000) enum ALGO ALGO_VER = ALGO_VER_DEFAULT; +enum UNITS UNITS = UNITS_DEFAULT; double SURFACE_PRESSURE = SURFACE_PRESSURE_DEFAULT; double P_WV = P_WV_DEFAULT; @@ -77,6 +78,37 @@ double msw_to_bar(double msw) return msw / 10; } +double bar_to_fsw(double bar) +{ + return (bar / 1.01325) * 33.0; +} + +double fsw_to_bar(double fsw) +{ + return (fsw * 1.01325) / 33.0; +} + +double msw_or_fsw(double msw, double fsw) +{ + assert(UNITS == METRIC || UNITS == IMPERIAL); + + return (UNITS == METRIC) ? msw : fsw; +} + +double xsw_to_bar(double xsw) +{ + assert(UNITS == METRIC || UNITS == IMPERIAL); + + return (UNITS == METRIC) ? msw_to_bar(xsw) : fsw_to_bar(xsw); +} + +double bar_to_xsw(double bar) +{ + assert(UNITS == METRIC || UNITS == IMPERIAL); + + return (UNITS == METRIC) ? bar_to_msw(bar) : bar_to_fsw(bar); +} + double abs_depth(double gd) { return gd + SURFACE_PRESSURE; |