diff options
author | Tim Segers <tsegers@pm.me> | 2022-10-16 16:58:24 +0200 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2022-10-16 16:58:24 +0200 |
commit | 0bbee8727d71c6546921195f09660972be4e3497 (patch) | |
tree | 436b22ff995ece136627a9bce92d02e709d38380 /src/schedule.c | |
parent | c9efb31b81fc5047dad568959c43e9ea06277473 (diff) | |
download | opendeco-0bbee8727d71c6546921195f09660972be4e3497.tar.gz |
Add rough-fine optimization to ndl calculation
Diffstat (limited to 'src/schedule.c')
-rw-r--r-- | src/schedule.c | 21 |
1 files changed, 19 insertions, 2 deletions
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; |