mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
When interpolating tank pressures, don't devide by zero
When an interpolated segment is on the surface we get no pressure time - and try to divide by zero. (plus a small whitespace issue that slipped throught the cracks earlier) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
eec5dba1c2
commit
fef4d15965
1 changed files with 10 additions and 7 deletions
|
@ -620,6 +620,8 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
||||||
#ifdef DEBUG_PR_INTERPOLATE
|
#ifdef DEBUG_PR_INTERPOLATE
|
||||||
dump_pr_interpolate(i, interpolate);
|
dump_pr_interpolate(i, interpolate);
|
||||||
#endif
|
#endif
|
||||||
|
/* if this segment had pressure time, set the interpolated pressure */
|
||||||
|
if (interpolate.pressure_time) {
|
||||||
/* Overall pressure change over total pressure-time for this segment*/
|
/* Overall pressure change over total pressure-time for this segment*/
|
||||||
magic = (interpolate.end - interpolate.start) / (double) interpolate.pressure_time;
|
magic = (interpolate.end - interpolate.start) / (double) interpolate.pressure_time;
|
||||||
|
|
||||||
|
@ -627,6 +629,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
||||||
cur_pr[cyl] = interpolate.start + magic * interpolate.acc_pressure_time + 0.5;
|
cur_pr[cyl] = interpolate.start + magic * interpolate.acc_pressure_time + 0.5;
|
||||||
INTERPOLATED_PRESSURE(entry) = cur_pr[cyl];
|
INTERPOLATED_PRESSURE(entry) = cur_pr[cyl];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_cylinder_index(struct dive *dive, struct event *ev)
|
int get_cylinder_index(struct dive *dive, struct event *ev)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue