summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ballistics.h3
-rw-r--r--include/constants.h1
-rw-r--r--include/context.h14
-rw-r--r--include/drag_model.h23
-rw-r--r--include/vector.h9
5 files changed, 37 insertions, 13 deletions
diff --git a/include/ballistics.h b/include/ballistics.h
index 84a883d..ab68c3f 100644
--- a/include/ballistics.h
+++ b/include/ballistics.h
@@ -2,6 +2,7 @@
#define ACE_BALLISTICS_H
#include "context.h"
+#include "drag_model.h"
double atmospheric_correction(double ballistic_coefficient,
double temperature,
@@ -13,7 +14,7 @@ double calculate_air_density(double temperature,
double pressure,
double relative_humidity);
-double retard(DragModel ballistic_model,
+double retard(DragFunction drag_function,
double ballistic_coefficient,
double velocity,
double temperature);
diff --git a/include/constants.h b/include/constants.h
index cfc9c80..026ff7b 100644
--- a/include/constants.h
+++ b/include/constants.h
@@ -9,5 +9,6 @@ static const double UNIVERSAL_GAS_CONSTANT = 8.31432;
static const double SPECIFIC_GAST_CONSTANT_DRY_AIR = 287.057036320950;
static const double STD_AIR_DENSITY_ICAO = 1.22498;
static const double STD_AIR_DENSITY_ASM = 1.20886;
+static const double BC_CONVERSION_FACTOR = 0.00068418;
#endif
diff --git a/include/context.h b/include/context.h
index 65b4585..5dfad31 100644
--- a/include/context.h
+++ b/include/context.h
@@ -6,17 +6,7 @@
#include <stdbool.h>
#include "ace.h"
-
-typedef enum {
- BC_UNKNOWN = 0,
- BC_G1,
- BC_G2,
- BC_G3,
- BC_G4,
- BC_G5,
- BC_G6,
- BC_G7,
-} DragModel;
+#include "drag_model.h"
typedef enum {
ICAO,
@@ -29,7 +19,7 @@ typedef struct {
double bore_height;
double muzzle_velocity;
double ballistic_coef;
- size_t drag_model;
+ DragFunction drag_model;
double twist_dir;
} GunConfig;
diff --git a/include/drag_model.h b/include/drag_model.h
index baf5f72..8c18bed 100644
--- a/include/drag_model.h
+++ b/include/drag_model.h
@@ -1,6 +1,29 @@
#ifndef DRAG_MODEL_H
#define DRAG_MODEL_H
+#include <stddef.h>
+typedef enum {
+ DRAG_G1,
+ DRAG_G2,
+ DRAG_G5,
+ DRAG_G6,
+ DRAG_G7,
+ DRAG_G8,
+ DRAG_COUNT
+} DragFunction;
+
+typedef struct {
+ size_t num_points;
+ const double *mach;
+ const double *cd;
+} DragModel;
+
+extern const DragModel drag_models[DRAG_COUNT];
+
+static inline const DragModel* get_drag_model(DragFunction func) {
+ if (func >= DRAG_COUNT) return NULL;
+ return &drag_models[func];
+}
#endif
diff --git a/include/vector.h b/include/vector.h
new file mode 100644
index 0000000..5b0d2de
--- /dev/null
+++ b/include/vector.h
@@ -0,0 +1,9 @@
+#pragma once
+#include "vector.h"
+#include <stdlib.h>
+
+typedef struct vector_t vector_t;
+
+vector_t* vector_new(void);
+void vector_ctr(vector_t* obj);
+void vector_dtr(vector_t* obj);