diff options
author | Tim Segers <tsegers@pm.me> | 2022-10-14 14:27:21 +0200 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2022-10-14 14:27:21 +0200 |
commit | 9ec5076b0f891b1dea64d165e622841ef4dfb1c0 (patch) | |
tree | 53f903d1d428bac20c4d53932f7882319ba3bcdf /src | |
parent | 9171c1be91b6ecdc29e04c41dd2d64ad97340198 (diff) | |
download | opendeco-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
Diffstat (limited to 'src')
-rw-r--r-- | src/deco.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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) |