diff options
author | Tim Segers <tsegers@pm.me> | 2023-08-08 20:48:27 +0200 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2023-08-21 20:54:41 +0200 |
commit | b4582977251dbf07c13c4d69a4f7be04e75612d6 (patch) | |
tree | 5d49111f98766bf06302b4dea851d580ae78d319 /src/deco.c | |
parent | c46ebe4b35e3a0ffebf00b0eaa31b842279396b6 (diff) | |
download | opendeco-develop.tar.gz |
Split unit conversion functions out from deco.cdevelop
Diffstat (limited to 'src/deco.c')
-rw-r--r-- | src/deco.c | 54 |
1 files changed, 1 insertions, 53 deletions
@@ -5,12 +5,11 @@ #include <stdbool.h> #include "deco.h" +#include "units.h" #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; double END_MAX = END_MAX_DEFAULT; @@ -65,57 +64,6 @@ const zhl_he_t ZHL16He[] = { {.t = 240.03, .a = 0.5119, .b = 0.9267}, }; -double bar_to_msw(double bar) -{ - return bar * 10; -} - -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; -} - -double gauge_depth(double ad) -{ - return ad - SURFACE_PRESSURE; -} - void add_segment_ascdec(decostate_t *ds, double dstart, double dend, double time, const gas_t *gas) { assert(time > 0); |