summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index ec03bf562..bf2a4b841 100644
--- a/dive.h
+++ b/dive.h
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
+#include <math.h>
#include <glib.h>
#include <glib/gstdio.h>
@@ -221,6 +222,14 @@ static inline int mbar_to_PSI(int mbar)
return to_PSI(p);
}
+/* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */
+static inline int interpolate(int a, int b, int part, int whole)
+{
+ /* It is doubtful that we actually need floating point for this, but whatever */
+ double x = (double) a * (whole - part) + (double) b * part;
+ return rint(x / whole);
+}
+
struct sample {
duration_t time;
depth_t depth;