aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/deco.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/deco.c')
-rw-r--r--src/deco.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/deco.c b/src/deco.c
index e1ea401..349c8e5 100644
--- a/src/deco.c
+++ b/src/deco.c
@@ -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;