From 0bbee8727d71c6546921195f09660972be4e3497 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Sun, 16 Oct 2022 16:58:24 +0200 Subject: Add rough-fine optimization to ndl calculation --- src/schedule.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/schedule.c b/src/schedule.c index 18ab946..bf5a8ec 100644 --- a/src/schedule.c +++ b/src/schedule.c @@ -77,11 +77,28 @@ void simulate_dive(decostate_t *ds, waypoint_t *waypoints, const int nof_waypoin double calc_ndl(decostate_t *ds, const double depth, const double ascrate, const gas_t *gas) { - decostate_t ds_ = *ds; double ndl = 0; + /* rough steps */ + decostate_t ds_ = *ds; + + while (ndl < 360) { + double tmp = add_segment_const(&ds_, depth, STOPLEN_ROUGH, gas); + + if (!direct_ascent(&ds_, depth, gauge_depth(depth) / ascrate, gas)) + break; + + ndl += tmp; + } + + /* fine steps */ + ds_ = *ds; + + if (ndl) + add_segment_const(&ds_, depth, ndl, gas); + while (ndl < 360) { - double tmp = add_segment_const(&ds_, depth, 1, gas); + double tmp = add_segment_const(&ds_, depth, STOPLEN_FINE, gas); if (!direct_ascent(&ds_, depth, gauge_depth(depth) / ascrate, gas)) break; -- cgit v1.2.3-70-g09d2