mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:53:23 +00:00
cleanup: move interpolate inline function to its own header file
This is not really related to struct dive, so let's move it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f9c3227975
commit
f728923c79
8 changed files with 22 additions and 11 deletions
|
@ -119,6 +119,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
import-shearwater.c
|
||||
import-suunto.c
|
||||
import-seac.c
|
||||
interpolate.h
|
||||
libdivecomputer.c
|
||||
libdivecomputer.h
|
||||
liquivision.c
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "errorhelper.h"
|
||||
#include "event.h"
|
||||
#include "extradata.h"
|
||||
#include "interpolate.h"
|
||||
#include "qthelper.h"
|
||||
#include "membuffer.h"
|
||||
#include "picture.h"
|
||||
|
|
11
core/dive.h
11
core/dive.h
|
@ -21,17 +21,6 @@ extern const char *cylinderuse_text[NUM_GAS_USE];
|
|||
extern const char *divemode_text_ui[];
|
||||
extern const char *divemode_text[];
|
||||
|
||||
/* 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 */
|
||||
if (whole) {
|
||||
double x = (double)a * (whole - part) + (double)b * part;
|
||||
return (int)lrint(x / whole);
|
||||
}
|
||||
return (a+b)/2;
|
||||
}
|
||||
|
||||
struct dive_site;
|
||||
struct dive_site_table;
|
||||
struct dive_table;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "event.h"
|
||||
#include "filterpreset.h"
|
||||
#include "fulltext.h"
|
||||
#include "interpolate.h"
|
||||
#include "planner.h"
|
||||
#include "qthelper.h"
|
||||
#include "gettext.h"
|
||||
|
|
16
core/interpolate.h
Normal file
16
core/interpolate.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef INTERPOLATE_H
|
||||
#define INTERPOLATE_H
|
||||
|
||||
/* 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 */
|
||||
if (whole) {
|
||||
double x = (double)a * (whole - part) + (double)b * part;
|
||||
return (int)lrint(x / whole);
|
||||
}
|
||||
return (a+b)/2;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -17,6 +17,7 @@
|
|||
#include "deco.h"
|
||||
#include "errorhelper.h"
|
||||
#include "event.h"
|
||||
#include "interpolate.h"
|
||||
#include "planner.h"
|
||||
#include "subsurface-time.h"
|
||||
#include "gettext.h"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "display.h"
|
||||
#include "divelist.h"
|
||||
#include "event.h"
|
||||
#include "interpolate.h"
|
||||
#include "sample.h"
|
||||
#include "subsurface-string.h"
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ HEADERS += \
|
|||
../../commands/command_edit_trip.h \
|
||||
../../commands/command_filter.h \
|
||||
../../commands/command_pictures.h \
|
||||
../../core/interpolate.h \
|
||||
../../core/libdivecomputer.h \
|
||||
../../core/cloudstorage.h \
|
||||
../../core/configuredivecomputerthreads.h \
|
||||
|
|
Loading…
Add table
Reference in a new issue