aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Tim Segers <tsegers@pm.me>2022-10-14 14:27:21 +0200
committerGravatar Tim Segers <tsegers@pm.me>2022-10-14 14:27:21 +0200
commit9ec5076b0f891b1dea64d165e622841ef4dfb1c0 (patch)
tree53f903d1d428bac20c4d53932f7882319ba3bcdf
parent9171c1be91b6ecdc29e04c41dd2d64ad97340198 (diff)
downloadopendeco-9ec5076b0f891b1dea64d165e622841ef4dfb1c0.tar.gz
Tether GF to first and last stop instead of first stop and surface
Also make an exception for when the last stop is at 6m. In that case, do not tether the GF to 6m, but instead treat 6m as if it was 3m. Fixes ~tsegers/opendeco#6
-rw-r--r--src/deco.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/deco.c b/src/deco.c
index 204a2a7..80853b8 100644
--- a/src/deco.c
+++ b/src/deco.c
@@ -197,18 +197,19 @@ double get_gf(const decostate_t *ds, const double depth)
const unsigned char lo = ds->gflo;
const unsigned char hi = ds->gfhi;
+ double last_stop_gauge = LAST_STOP_AT_SIX ? 2 * ds->ceil_multiple : ds->ceil_multiple;
+
if (ds->firststop == -1)
return lo;
- if (depth < SURFACE_PRESSURE)
+ if (depth <= SURFACE_PRESSURE + last_stop_gauge)
return hi;
- if (depth > ds->firststop)
+ if (depth >= ds->firststop)
return lo;
- /* interpolate lo and hi between first stop and surface */
- double next_stop = depth - ds->ceil_multiple;
- return hi - (hi - lo) * gauge_depth(next_stop) / gauge_depth(ds->firststop);
+ /* interpolate lo and hi between first stop and last stop */
+ return hi - (hi - lo) * gauge_depth(depth - ds->ceil_multiple) / gauge_depth(ds->firststop - ds->ceil_multiple);
}
double round_ceiling(const decostate_t *ds, const double c)