ballistic-solve 0.0.1__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. {ballistic_solve-0.0.1 → ballistic_solve-0.2.0}/CMakeLists.txt +0 -3
  2. ballistic_solve-0.2.0/PKG-INFO +114 -0
  3. ballistic_solve-0.2.0/README.md +80 -0
  4. ballistic_solve-0.2.0/core/CMakeLists.txt +46 -0
  5. ballistic_solve-0.2.0/core/include/ballistic_solve/ballistic.hpp +266 -0
  6. ballistic_solve-0.2.0/core/include/ballistic_solve/constants.hpp +29 -0
  7. ballistic_solve-0.2.0/core/include/ballistic_solve/environment.hpp +197 -0
  8. ballistic_solve-0.2.0/core/include/ballistic_solve/projectile.hpp +193 -0
  9. ballistic_solve-0.2.0/core/include/ballistic_solve/utility.hpp +35 -0
  10. ballistic_solve-0.2.0/core/src/ballistic.cpp +517 -0
  11. ballistic_solve-0.2.0/core/src/environment.cpp +145 -0
  12. ballistic_solve-0.2.0/core/src/projectile.cpp +161 -0
  13. ballistic_solve-0.2.0/core/src/utility.cpp +19 -0
  14. ballistic_solve-0.2.0/docs/images/hero-dark.png +0 -0
  15. {ballistic_solve-0.0.1 → ballistic_solve-0.2.0}/environment.yml +6 -1
  16. ballistic_solve-0.2.0/pyproject.toml +51 -0
  17. {ballistic_solve-0.0.1 → ballistic_solve-0.2.0}/python/CMakeLists.txt +11 -4
  18. ballistic_solve-0.2.0/python/src/ballistic_solve/__init__.py +16 -0
  19. ballistic_solve-0.2.0/python/src/bindings.cpp +485 -0
  20. ballistic_solve-0.2.0/test.py +25 -0
  21. ballistic_solve-0.0.1/PKG-INFO +0 -58
  22. ballistic_solve-0.0.1/README.md +0 -28
  23. ballistic_solve-0.0.1/core/CMakeLists.txt +0 -64
  24. ballistic_solve-0.0.1/core/include/ballistic-solve/environment.hpp +0 -124
  25. ballistic_solve-0.0.1/core/include/ballistic-solve/platform.hpp +0 -43
  26. ballistic_solve-0.0.1/core/include/ballistic-solve/projectile.hpp +0 -41
  27. ballistic_solve-0.0.1/core/include/ballistic-solve/simulation.hpp +0 -132
  28. ballistic_solve-0.0.1/core/include/ballistic-solve/targeting.hpp +0 -255
  29. ballistic_solve-0.0.1/core/include/ballistic-solve/tools.hpp +0 -77
  30. ballistic_solve-0.0.1/core/include/ballistic-solve/trajectory.hpp +0 -51
  31. ballistic_solve-0.0.1/core/src/environment.cpp +0 -91
  32. ballistic_solve-0.0.1/core/src/platform.cpp +0 -14
  33. ballistic_solve-0.0.1/core/src/projectile.cpp +0 -14
  34. ballistic_solve-0.0.1/core/src/simulation.cpp +0 -179
  35. ballistic_solve-0.0.1/core/src/targeting.cpp +0 -433
  36. ballistic_solve-0.0.1/core/src/tools.cpp +0 -98
  37. ballistic_solve-0.0.1/core/src/trajectory.cpp +0 -21
  38. ballistic_solve-0.0.1/pyproject.toml +0 -16
  39. ballistic_solve-0.0.1/python/src/ballistic-solve/__init__.py +0 -64
  40. ballistic_solve-0.0.1/python/src/ballistic-solve/_core.pyi +0 -553
  41. ballistic_solve-0.0.1/python/src/bindings.cpp +0 -546
  42. ballistic_solve-0.0.1/test.py +0 -440
  43. {ballistic_solve-0.0.1 → ballistic_solve-0.2.0}/.gitignore +0 -0
  44. {ballistic_solve-0.0.1 → ballistic_solve-0.2.0}/LICENSE +0 -0
@@ -1,8 +1,5 @@
1
1
  cmake_minimum_required(VERSION 4.2)
2
2
  project(ballistic-solve)
3
3
 
4
- set(CMAKE_CXX_STANDARD 20)
5
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
6
-
7
4
  add_subdirectory(core)
8
5
  add_subdirectory(python)
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.2
2
+ Name: ballistic-solve
3
+ Version: 0.2.0
4
+ Summary: Real-time numerical solver for moving target interception with realistic ballistic trajectory
5
+ Keywords: ballistic,trajectory,projectile,physics-simulation,ballistics-solver,ode-solver,numerical-integration,root-finding,optimization,fire-control,targeting,intercept,weapon-systems,aerospace,drag-coefficient,atmospheric-effects,wind-compensation,gravity,adaptive-stepping,real-time,scientific-computing
6
+ Author-Email: Ariyudo Pertama <yudojago@gmail.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 Ariyudo Pertama
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Classifier: Programming Language :: Python :: 3
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Requires-Python: >=3.12
32
+ Requires-Dist: numpy
33
+ Description-Content-Type: text/markdown
34
+
35
+ <div align="center">
36
+
37
+ <picture>
38
+ <source media="(prefers-color-scheme: dark)" srcset="docs/images/hero-dark.png">
39
+ <source media="(prefers-color-scheme: light)" srcset="docs/images/hero-dark.png">
40
+ <img alt="ballistic-solve" src="docs/images/hero-light.png" width="70%">
41
+ </picture>
42
+
43
+ [![PyPI](https://img.shields.io/pypi/v/ballistic-solve.svg)](https://pypi.org/project/ballistic-solve/)
44
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
45
+ [![C++](https://img.shields.io/badge/C++-20-00599C.svg)](https://isocpp.org/)
46
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
47
+
48
+ </div>
49
+
50
+ **ballistic-solve** is a high-performance C++ library with Python bindings for computing ballistic trajectories and firing solutions. It solves intercept problems for moving targets while modeling real-world physics including gravity, drag, wind, and atmospheric variations.
51
+
52
+ ### Key Features
53
+
54
+ - **Real-world physics** — Account for gravity, air resistance, wind, and atmospheric conditions
55
+ - **Moving targets interception** — Calculate firing solutions to intercept targets with any motion pattern
56
+ - **High performance** — Fast C++ core with Eigen for real-time trajectory computation
57
+
58
+ ---
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install ballistic-solve
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Quick Start
69
+
70
+ ```python
71
+ import numpy as np
72
+ from ballistic_solve import Ballistic, Environment, Projectile
73
+
74
+ environment = Environment.earth_standard()
75
+ projectile = Projectile.gsh30_round()
76
+
77
+ ballistic = Ballistic(environment, projectile)
78
+
79
+ def target_position(t):
80
+ p = np.array([1200.0, 150.0, 5200.0])
81
+ v = np.array([270.0, 20.0, -5.0])
82
+ a = np.array([0.0, -15.0, -2.0])
83
+
84
+ return p + v * t + 0.5 * a * t**2
85
+
86
+ solution = ballistic.solve_earliest(
87
+ target_position=target_position,
88
+ platform_position=np.array([0.0, 0.0, 5000.0]),
89
+ platform_velocity=np.array([250.0, 0.0, 0.0]),
90
+ projectile_speed=860.0,
91
+ time_range=(0.0, 5.0)
92
+ )
93
+
94
+ if solution:
95
+ print(f"Fire direction: {solution.direction}")
96
+ print(f"Time to intercept: {solution.time:.3f}s")
97
+ print(f"Interception error: {solution.error:.4e}m")
98
+ print(f"Computation time: {solution.computation_time * 1e3:.2f}ms")
99
+ else:
100
+ print("No solution")
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Dependencies
106
+
107
+ - **Eigen** — Vectorized linear algebra and Levenberg-Marquardt optimization
108
+ - **Boost** — Adaptive-step ODE integration and root-finding
109
+
110
+ ---
111
+
112
+ ## License
113
+
114
+ [MIT](LICENSE) © Ariyudo Pertama
@@ -0,0 +1,80 @@
1
+ <div align="center">
2
+
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="docs/images/hero-dark.png">
5
+ <source media="(prefers-color-scheme: light)" srcset="docs/images/hero-dark.png">
6
+ <img alt="ballistic-solve" src="docs/images/hero-light.png" width="70%">
7
+ </picture>
8
+
9
+ [![PyPI](https://img.shields.io/pypi/v/ballistic-solve.svg)](https://pypi.org/project/ballistic-solve/)
10
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
11
+ [![C++](https://img.shields.io/badge/C++-20-00599C.svg)](https://isocpp.org/)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
13
+
14
+ </div>
15
+
16
+ **ballistic-solve** is a high-performance C++ library with Python bindings for computing ballistic trajectories and firing solutions. It solves intercept problems for moving targets while modeling real-world physics including gravity, drag, wind, and atmospheric variations.
17
+
18
+ ### Key Features
19
+
20
+ - **Real-world physics** — Account for gravity, air resistance, wind, and atmospheric conditions
21
+ - **Moving targets interception** — Calculate firing solutions to intercept targets with any motion pattern
22
+ - **High performance** — Fast C++ core with Eigen for real-time trajectory computation
23
+
24
+ ---
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install ballistic-solve
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Quick Start
35
+
36
+ ```python
37
+ import numpy as np
38
+ from ballistic_solve import Ballistic, Environment, Projectile
39
+
40
+ environment = Environment.earth_standard()
41
+ projectile = Projectile.gsh30_round()
42
+
43
+ ballistic = Ballistic(environment, projectile)
44
+
45
+ def target_position(t):
46
+ p = np.array([1200.0, 150.0, 5200.0])
47
+ v = np.array([270.0, 20.0, -5.0])
48
+ a = np.array([0.0, -15.0, -2.0])
49
+
50
+ return p + v * t + 0.5 * a * t**2
51
+
52
+ solution = ballistic.solve_earliest(
53
+ target_position=target_position,
54
+ platform_position=np.array([0.0, 0.0, 5000.0]),
55
+ platform_velocity=np.array([250.0, 0.0, 0.0]),
56
+ projectile_speed=860.0,
57
+ time_range=(0.0, 5.0)
58
+ )
59
+
60
+ if solution:
61
+ print(f"Fire direction: {solution.direction}")
62
+ print(f"Time to intercept: {solution.time:.3f}s")
63
+ print(f"Interception error: {solution.error:.4e}m")
64
+ print(f"Computation time: {solution.computation_time * 1e3:.2f}ms")
65
+ else:
66
+ print("No solution")
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Dependencies
72
+
73
+ - **Eigen** — Vectorized linear algebra and Levenberg-Marquardt optimization
74
+ - **Boost** — Adaptive-step ODE integration and root-finding
75
+
76
+ ---
77
+
78
+ ## License
79
+
80
+ [MIT](LICENSE) © Ariyudo Pertama
@@ -0,0 +1,46 @@
1
+ cmake_minimum_required(VERSION 4.2)
2
+ project(
3
+ ballistic_solve_core
4
+ VERSION 0.2.0
5
+ LANGUAGES CXX
6
+ )
7
+
8
+ find_package(Boost REQUIRED)
9
+ find_package(Eigen3 REQUIRED)
10
+
11
+ add_library(ballistic_solve_core STATIC
12
+ src/ballistic.cpp
13
+ src/environment.cpp
14
+ src/projectile.cpp
15
+ src/utility.cpp
16
+ )
17
+
18
+ target_sources(ballistic_solve_core
19
+ PUBLIC
20
+ FILE_SET HEADERS
21
+ BASE_DIRS include
22
+ FILES
23
+ include/ballistic_solve/ballistic.hpp
24
+ include/ballistic_solve/environment.hpp
25
+ include/ballistic_solve/projectile.hpp
26
+ include/ballistic_solve/utility.hpp
27
+ include/ballistic_solve/constants.hpp
28
+ )
29
+
30
+ target_include_directories(ballistic_solve_core
31
+ PUBLIC
32
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
33
+ $<INSTALL_INTERFACE:include>
34
+ )
35
+
36
+ target_link_libraries(ballistic_solve_core
37
+ PUBLIC
38
+ Boost::boost
39
+ Eigen3::Eigen
40
+ )
41
+
42
+ target_compile_features(ballistic_solve_core PUBLIC cxx_std_20)
43
+
44
+ set_target_properties(ballistic_solve_core PROPERTIES
45
+ POSITION_INDEPENDENT_CODE ON
46
+ )
@@ -0,0 +1,266 @@
1
+ #ifndef BALLISTIC_SOLVE_BALLISTIC_HPP
2
+ #define BALLISTIC_SOLVE_BALLISTIC_HPP
3
+
4
+ #include "./environment.hpp"
5
+ #include "./projectile.hpp"
6
+ #include <Eigen/dense>
7
+ #include <optional>
8
+ #include <functional>
9
+ #include <vector>
10
+
11
+ namespace ballistic_solve
12
+ {
13
+ /**
14
+ * @brief Ballistic trajectory solver for projectile motion with environmental effects.
15
+ *
16
+ * This class provides methods to simulate projectile trajectories and solve firing
17
+ * solutions for moving or stationary targets. It accounts for gravity, air drag,
18
+ * wind, and other environmental factors.
19
+ */
20
+ class Ballistic
21
+ {
22
+ private:
23
+ /**
24
+ * @brief State vector representation: [position_x, position_y, position_z, velocity_x, velocity_y, velocity_z]
25
+ */
26
+ using State = Eigen::Matrix<double, 6, 1>;
27
+
28
+ /**
29
+ * @brief Function type for time-varying target position.
30
+ *
31
+ * @param time Time in seconds
32
+ * @return Target position vector at the given time
33
+ */
34
+ using TargetPosition = std::function<Eigen::Vector3d(double)>;
35
+
36
+ public:
37
+ /**
38
+ * @brief Contains the computed trajectory of a projectile.
39
+ */
40
+ struct Trajectory
41
+ {
42
+ /** @brief Sequence of 3D positions along the trajectory in meters */
43
+ const std::vector<Eigen::Vector3d> positions;
44
+
45
+ /** @brief Corresponding time values for each position in seconds */
46
+ const std::vector<double> times;
47
+ };
48
+
49
+ /**
50
+ * @brief Contains a firing solution for intercepting a target.
51
+ */
52
+ struct Solution
53
+ {
54
+ /** @brief Unit direction vector to aim the projectile */
55
+ const Eigen::Vector3d direction;
56
+
57
+ /** @brief Time of intercept in seconds */
58
+ const double time;
59
+
60
+ /** @brief Intercept error in meters */
61
+ const double error;
62
+
63
+ /** @brief Computation time in seconds */
64
+ const double computation_time;
65
+ };
66
+
67
+ public:
68
+ /** @brief Environmental conditions affecting the projectile */
69
+ const Environment environment;
70
+
71
+ /** @brief Physical properties of the projectile */
72
+ const Projectile projectile;
73
+
74
+ public:
75
+ /**
76
+ * @brief Constructs a ballistic solver with given environment and projectile.
77
+ *
78
+ * @param environment Environmental conditions (gravity, air density, wind, temperature)
79
+ * @param projectile Projectile properties (mass, area, drag coefficient)
80
+ */
81
+ Ballistic(
82
+ Environment environment,
83
+ Projectile projectile);
84
+
85
+ public:
86
+ /**
87
+ * @brief Simulates projectile trajectory over a time range with specified direction.
88
+ *
89
+ * @param platform_position Initial position of the launching platform in meters
90
+ * @param platform_velocity Velocity of the launching platform in m/s
91
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
92
+ * @param direction Unit direction vector for the projectile launch
93
+ * @param time_range Time interval [start, end] for simulation in seconds
94
+ * @return Trajectory containing positions and times along the flight path
95
+ */
96
+ [[nodiscard]] Trajectory simulate(
97
+ const Eigen::Vector3d &platform_position,
98
+ const Eigen::Vector3d &platform_velocity,
99
+ double projectile_speed,
100
+ const Eigen::Vector3d &direction,
101
+ std::pair<double, double> time_range) const;
102
+
103
+ /**
104
+ * @brief Simulates projectile trajectory over a time range with specified angles.
105
+ *
106
+ * @param platform_position Initial position of the launching platform in meters
107
+ * @param platform_velocity Velocity of the launching platform in m/s
108
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
109
+ * @param angles Launch angles [azimuth, elevation] in radians
110
+ * @param time_range Time interval [start, end] for simulation in seconds
111
+ * @return Trajectory containing positions and times along the flight path
112
+ */
113
+ [[nodiscard]] Trajectory simulate(
114
+ const Eigen::Vector3d &platform_position,
115
+ const Eigen::Vector3d &platform_velocity,
116
+ double projectile_speed,
117
+ const Eigen::Vector2d &angles,
118
+ std::pair<double, double> time_range) const;
119
+
120
+ /**
121
+ * @brief Simulates projectile position at a specific time with specified direction.
122
+ *
123
+ * @param platform_position Initial position of the launching platform in meters
124
+ * @param platform_velocity Velocity of the launching platform in m/s
125
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
126
+ * @param direction Unit direction vector for the projectile launch
127
+ * @param time Time at which to compute position in seconds
128
+ * @return Projectile position at the specified time in meters
129
+ */
130
+ [[nodiscard]] Eigen::Vector3d simulate(
131
+ const Eigen::Vector3d &platform_position,
132
+ const Eigen::Vector3d &platform_velocity,
133
+ double projectile_speed,
134
+ const Eigen::Vector3d &direction,
135
+ double time) const;
136
+
137
+ /**
138
+ * @brief Simulates projectile position at a specific time with specified angles.
139
+ *
140
+ * @param platform_position Initial position of the launching platform in meters
141
+ * @param platform_velocity Velocity of the launching platform in m/s
142
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
143
+ * @param angles Launch angles [azimuth, elevation] in radians
144
+ * @param time Time at which to compute position in seconds
145
+ * @return Projectile position at the specified time in meters
146
+ */
147
+ [[nodiscard]] Eigen::Vector3d simulate(
148
+ const Eigen::Vector3d &platform_position,
149
+ const Eigen::Vector3d &platform_velocity,
150
+ double projectile_speed,
151
+ const Eigen::Vector2d &angles,
152
+ double time) const;
153
+
154
+ /**
155
+ * @brief Finds the earliest firing solution to intercept a moving target.
156
+ *
157
+ * Searches for the earliest time within the specified range where the projectile
158
+ * can intercept the target. Uses a time-scanning approach with the given interval.
159
+ *
160
+ * @param target_position Function providing target position as a function of time
161
+ * @param platform_position Initial position of the launching platform in meters
162
+ * @param platform_velocity Velocity of the launching platform in m/s
163
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
164
+ * @param time_range Time interval [start, end] to search for solutions in seconds
165
+ * @param time_scan_interval Time step for scanning potential intercept times (default: 0.5 s)
166
+ * @return Optional Solution containing firing direction and intercept time, or nullopt if no solution exists
167
+ */
168
+ [[nodiscard]] std::optional<Solution> solve_earliest(
169
+ TargetPosition target_position,
170
+ const Eigen::Vector3d &platform_position,
171
+ const Eigen::Vector3d &platform_velocity,
172
+ double projectile_speed,
173
+ std::pair<double, double> time_range,
174
+ double time_scan_interval = 0.5) const;
175
+
176
+ /**
177
+ * @brief Finds the latest firing solution to intercept a moving target.
178
+ *
179
+ * Searches for the latest time within the specified range where the projectile
180
+ * can intercept the target. Uses a time-scanning approach with the given interval.
181
+ *
182
+ * @param target_position Function providing target position as a function of time
183
+ * @param platform_position Initial position of the launching platform in meters
184
+ * @param platform_velocity Velocity of the launching platform in m/s
185
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
186
+ * @param time_range Time interval [start, end] to search for solutions in seconds
187
+ * @param time_scan_interval Time step for scanning potential intercept times (default: 0.5 s)
188
+ * @return Optional Solution containing firing direction and intercept time, or nullopt if no solution exists
189
+ */
190
+ [[nodiscard]] std::optional<Solution> solve_latest(
191
+ TargetPosition target_position,
192
+ const Eigen::Vector3d &platform_position,
193
+ const Eigen::Vector3d &platform_velocity,
194
+ double projectile_speed,
195
+ std::pair<double, double> time_range,
196
+ double time_scan_interval = 0.5) const;
197
+
198
+ /**
199
+ * @brief Finds optimal launch angles to hit a stationary target at a specific time.
200
+ *
201
+ * Computes the azimuth and elevation angles that minimize the intercept error
202
+ * for reaching the target position at the specified time.
203
+ *
204
+ * @param target_position Position of the target in meters
205
+ * @param platform_position Initial position of the launching platform in meters
206
+ * @param platform_velocity Velocity of the launching platform in m/s
207
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
208
+ * @param time Time at which intercept should occur in seconds
209
+ * @return Optimal launch angles [azimuth, elevation] in radians
210
+ */
211
+ [[nodiscard]] Eigen::Vector2d find_best_angles(
212
+ const Eigen::Vector3d &target_position,
213
+ const Eigen::Vector3d &platform_position,
214
+ const Eigen::Vector3d &platform_velocity,
215
+ double projectile_speed,
216
+ double time) const;
217
+
218
+ /**
219
+ * @brief Finds optimal launch direction to hit a stationary target at a specific time.
220
+ *
221
+ * Computes the direction that minimize the intercept error
222
+ * for reaching the target position at the specified time.
223
+ *
224
+ * @param target_position Position of the target in meters
225
+ * @param platform_position Initial position of the launching platform in meters
226
+ * @param platform_velocity Velocity of the launching platform in m/s
227
+ * @param projectile_speed Muzzle speed of the projectile relative to platform in m/s
228
+ * @param time Time at which intercept should occur in seconds
229
+ * @return Optimal launch direction
230
+ */
231
+ [[nodiscard]] Eigen::Vector3d find_best_direction(
232
+ const Eigen::Vector3d &target_position,
233
+ const Eigen::Vector3d &platform_position,
234
+ const Eigen::Vector3d &platform_velocity,
235
+ double projectile_speed,
236
+ double time) const;
237
+
238
+ private:
239
+ void system(const State &x, State &dxdt, double time) const;
240
+
241
+ [[nodiscard]] Trajectory simulate(
242
+ const Eigen::Vector3d &platform_position,
243
+ const Eigen::Vector3d &platform_velocity,
244
+ double projectile_speed,
245
+ const Eigen::Vector3d &direction,
246
+ bool is_normalized_direction,
247
+ std::pair<double, double> time_range) const;
248
+
249
+ [[nodiscard]] Eigen::Vector3d simulate(
250
+ const Eigen::Vector3d &platform_position,
251
+ const Eigen::Vector3d &platform_velocity,
252
+ double projectile_speed,
253
+ const Eigen::Vector3d &direction,
254
+ bool is_normalized_direction,
255
+ double time) const;
256
+
257
+ [[nodiscard]] double intercept_error(
258
+ Ballistic::TargetPosition target_position,
259
+ const Eigen::Vector3d &platform_position,
260
+ const Eigen::Vector3d &platform_velocity,
261
+ double projectile_speed,
262
+ double time) const;
263
+ };
264
+ }
265
+
266
+ #endif // BALLISTIC_SOLVE_BALLISTIC_HPP
@@ -0,0 +1,29 @@
1
+ #ifndef BALLISTIC_SOLVE_CONSTANTS_HPP
2
+ #define BALLISTIC_SOLVE_CONSTANTS_HPP
3
+
4
+ #include <boost/math/tools/roots.hpp>
5
+ #include <limits>
6
+
7
+ namespace ballistic_solve
8
+ {
9
+ namespace constants
10
+ {
11
+ inline constexpr int digits = std::numeric_limits<double>::digits;
12
+ inline constexpr double h = 1e-6;
13
+
14
+ namespace root_finding {
15
+ inline const boost::math::tools::eps_tolerance<double> tolerance(digits);
16
+ inline constexpr std::uintmax_t max_iterations = 40;
17
+ }
18
+
19
+ namespace integration
20
+ {
21
+ inline constexpr double max_step_size = std::numeric_limits<double>::infinity();
22
+ inline constexpr double initial_step_size = 1e-3;
23
+ inline constexpr double abs_tolerance = 1e-6;
24
+ inline constexpr double rel_tolerance = 1e-3;
25
+ }
26
+ }
27
+ }
28
+
29
+ #endif // BALLISTIC_SOLVE_CONSTANTS_HPP