ballistic-solve 0.0.1__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.
- ballistic_solve-0.0.1/.gitignore +71 -0
- ballistic_solve-0.0.1/CMakeLists.txt +8 -0
- ballistic_solve-0.0.1/LICENSE +21 -0
- ballistic_solve-0.0.1/PKG-INFO +58 -0
- ballistic_solve-0.0.1/README.md +28 -0
- ballistic_solve-0.0.1/core/CMakeLists.txt +64 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/environment.hpp +124 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/platform.hpp +43 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/projectile.hpp +41 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/simulation.hpp +132 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/targeting.hpp +255 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/tools.hpp +77 -0
- ballistic_solve-0.0.1/core/include/ballistic-solve/trajectory.hpp +51 -0
- ballistic_solve-0.0.1/core/src/environment.cpp +91 -0
- ballistic_solve-0.0.1/core/src/platform.cpp +14 -0
- ballistic_solve-0.0.1/core/src/projectile.cpp +14 -0
- ballistic_solve-0.0.1/core/src/simulation.cpp +179 -0
- ballistic_solve-0.0.1/core/src/targeting.cpp +433 -0
- ballistic_solve-0.0.1/core/src/tools.cpp +98 -0
- ballistic_solve-0.0.1/core/src/trajectory.cpp +21 -0
- ballistic_solve-0.0.1/environment.yml +11 -0
- ballistic_solve-0.0.1/pyproject.toml +16 -0
- ballistic_solve-0.0.1/python/CMakeLists.txt +43 -0
- ballistic_solve-0.0.1/python/src/ballistic-solve/__init__.py +64 -0
- ballistic_solve-0.0.1/python/src/ballistic-solve/_core.pyi +553 -0
- ballistic_solve-0.0.1/python/src/bindings.cpp +546 -0
- ballistic_solve-0.0.1/test.py +440 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.installed.cfg
|
|
8
|
+
*.egg
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
*.whl
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
ENV/
|
|
17
|
+
env/
|
|
18
|
+
.pixi/
|
|
19
|
+
|
|
20
|
+
# IDEs
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
|
|
24
|
+
# CMake
|
|
25
|
+
.cmake/
|
|
26
|
+
CMakeCache.txt
|
|
27
|
+
CMakeFiles/
|
|
28
|
+
cmake_install.cmake
|
|
29
|
+
Makefile
|
|
30
|
+
*.vcxproj
|
|
31
|
+
*.vcxproj.filters
|
|
32
|
+
*.sln
|
|
33
|
+
|
|
34
|
+
# Build directories
|
|
35
|
+
build/
|
|
36
|
+
out/
|
|
37
|
+
Debug/
|
|
38
|
+
Release/
|
|
39
|
+
RelWithDebInfo/
|
|
40
|
+
MinSizeRel/
|
|
41
|
+
|
|
42
|
+
# Compiled binaries
|
|
43
|
+
*.exe
|
|
44
|
+
*.dll
|
|
45
|
+
*.dylib
|
|
46
|
+
*.so
|
|
47
|
+
*.pyd
|
|
48
|
+
|
|
49
|
+
# OS
|
|
50
|
+
.DS_Store
|
|
51
|
+
Thumbs.db
|
|
52
|
+
*.swp
|
|
53
|
+
*.swo
|
|
54
|
+
*~
|
|
55
|
+
|
|
56
|
+
# Testing
|
|
57
|
+
.pytest_cache/
|
|
58
|
+
.coverage
|
|
59
|
+
htmlcov/
|
|
60
|
+
*.cover
|
|
61
|
+
|
|
62
|
+
# Environment files
|
|
63
|
+
.env
|
|
64
|
+
.envrc
|
|
65
|
+
|
|
66
|
+
# Jupyter
|
|
67
|
+
.ipynb_checkpoints/
|
|
68
|
+
|
|
69
|
+
# Numba cache (from your __pycache__ listing)
|
|
70
|
+
*.nbc
|
|
71
|
+
*.nbi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ariyudo Pertama
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: ballistic-solve
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Ballistic trajectory solver with C++ core and Python bindings
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 Ariyudo Pertama
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Requires-Dist: numpy
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# ballistic-solve
|
|
32
|
+
|
|
33
|
+
Ballistic trajectory simulation and fire control solutions.
|
|
34
|
+
|
|
35
|
+
## Development Setup
|
|
36
|
+
|
|
37
|
+
### Prerequisites
|
|
38
|
+
- Miniforge (or Conda/Miniconda)
|
|
39
|
+
|
|
40
|
+
### Installation
|
|
41
|
+
|
|
42
|
+
1. **Create the conda environment:**
|
|
43
|
+
```bat
|
|
44
|
+
conda env create --file environment.yml
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. **Activate the environment:**
|
|
48
|
+
```bat
|
|
49
|
+
conda activate ballistic-solve
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Development
|
|
53
|
+
|
|
54
|
+
Work in progress. More documentation coming soon.
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ballistic-solve
|
|
2
|
+
|
|
3
|
+
Ballistic trajectory simulation and fire control solutions.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
- Miniforge (or Conda/Miniconda)
|
|
9
|
+
|
|
10
|
+
### Installation
|
|
11
|
+
|
|
12
|
+
1. **Create the conda environment:**
|
|
13
|
+
```bat
|
|
14
|
+
conda env create --file environment.yml
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. **Activate the environment:**
|
|
18
|
+
```bat
|
|
19
|
+
conda activate ballistic-solve
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Development
|
|
23
|
+
|
|
24
|
+
Work in progress. More documentation coming soon.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 4.2)
|
|
2
|
+
project(
|
|
3
|
+
ballistic_solve_core
|
|
4
|
+
VERSION 0.0.0
|
|
5
|
+
LANGUAGES CXX
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
9
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
10
|
+
|
|
11
|
+
find_package(Boost REQUIRED)
|
|
12
|
+
find_package(Eigen3 REQUIRED)
|
|
13
|
+
|
|
14
|
+
set(BALLISTIC_SOLVE_CORE_HEADERS
|
|
15
|
+
include/ballistic-solve/environment.hpp
|
|
16
|
+
include/ballistic-solve/platform.hpp
|
|
17
|
+
include/ballistic-solve/projectile.hpp
|
|
18
|
+
include/ballistic-solve/simulation.hpp
|
|
19
|
+
include/ballistic-solve/trajectory.hpp
|
|
20
|
+
include/ballistic-solve/targeting.hpp
|
|
21
|
+
include/ballistic-solve/tools.hpp
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
set(BALLISTIC_SOLVE_CORE_SOURCES
|
|
25
|
+
src/environment.cpp
|
|
26
|
+
src/platform.cpp
|
|
27
|
+
src/projectile.cpp
|
|
28
|
+
src/simulation.cpp
|
|
29
|
+
src/trajectory.cpp
|
|
30
|
+
src/targeting.cpp
|
|
31
|
+
src/tools.cpp
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
set(PRIVATE_REQUIRED_EXTERNAL_LIBRARIES
|
|
35
|
+
Boost::boost
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
set(PUBLIC_REQUIRED_EXTERNAL_LIBRARIES
|
|
39
|
+
Eigen3::Eigen
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
add_library(ballistic_solve_core STATIC)
|
|
43
|
+
|
|
44
|
+
target_sources(ballistic_solve_core
|
|
45
|
+
PUBLIC
|
|
46
|
+
${BALLISTIC_SOLVE_CORE_HEADERS}
|
|
47
|
+
PRIVATE
|
|
48
|
+
${BALLISTIC_SOLVE_CORE_SOURCES}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
target_include_directories(ballistic_solve_core
|
|
52
|
+
PUBLIC
|
|
53
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
54
|
+
$<INSTALL_INTERFACE:include>
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
target_link_libraries(ballistic_solve_core
|
|
58
|
+
PRIVATE
|
|
59
|
+
${PRIVATE_REQUIRED_EXTERNAL_LIBRARIES}
|
|
60
|
+
PUBLIC
|
|
61
|
+
${PUBLIC_REQUIRED_EXTERNAL_LIBRARIES}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
set_target_properties(ballistic_solve_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#ifndef BALLISTIC_SOLVE_ENVIRONMENT_HPP
|
|
2
|
+
#define BALLISTIC_SOLVE_ENVIRONMENT_HPP
|
|
3
|
+
|
|
4
|
+
#include <functional>
|
|
5
|
+
#include <optional>
|
|
6
|
+
#include <Eigen/Dense>
|
|
7
|
+
|
|
8
|
+
namespace ballistic_solve
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* @brief Environmental conditions for ballistic simulation.
|
|
12
|
+
*
|
|
13
|
+
* Encapsulates atmospheric and gravitational conditions affecting projectile motion,
|
|
14
|
+
* including gravity, altitude-dependent air density, and wind velocity.
|
|
15
|
+
*/
|
|
16
|
+
class Environment
|
|
17
|
+
{
|
|
18
|
+
public:
|
|
19
|
+
/// Function type for air density as a function of altitude: ρ(h) in kg/m³
|
|
20
|
+
using AirDensity = std::function<double(double)>;
|
|
21
|
+
|
|
22
|
+
/// Gravitational acceleration vector in m/s² (typically [0, 0, -9.81])
|
|
23
|
+
const Eigen::Vector3d gravity;
|
|
24
|
+
|
|
25
|
+
/// Air density function ρ(altitude) in kg/m³, where altitude is in meters
|
|
26
|
+
const AirDensity air_density;
|
|
27
|
+
|
|
28
|
+
/// Wind velocity vector in m/s
|
|
29
|
+
const Eigen::Vector3d wind_velocity;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @brief Construct a custom environment.
|
|
33
|
+
*
|
|
34
|
+
* @param gravity Gravitational acceleration vector (m/s²)
|
|
35
|
+
* @param air_density Function mapping altitude (m) to air density (kg/m³)
|
|
36
|
+
* @param wind_velocity Wind velocity vector (m/s)
|
|
37
|
+
*/
|
|
38
|
+
Environment(
|
|
39
|
+
const Eigen::Vector3d &gravity,
|
|
40
|
+
const AirDensity &air_density,
|
|
41
|
+
const Eigen::Vector3d &wind_velocity);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @brief Create a vacuum environment (no air, no wind).
|
|
45
|
+
*
|
|
46
|
+
* Uses standard gravity but zero air density everywhere.
|
|
47
|
+
* Useful for testing or space-like conditions.
|
|
48
|
+
*
|
|
49
|
+
* @return Environment Vacuum environment with g = -9.81 m/s²
|
|
50
|
+
*/
|
|
51
|
+
static Environment vacuum();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @brief Create standard Earth atmosphere at sea level.
|
|
55
|
+
*
|
|
56
|
+
* Uses:
|
|
57
|
+
* - Standard gravity: 9.81 m/s² (downward)
|
|
58
|
+
* - Exponential atmosphere: ρ(h) = 1.225 * exp(-h/8500) kg/m³
|
|
59
|
+
* - No wind
|
|
60
|
+
*
|
|
61
|
+
* @return Environment Standard Earth conditions
|
|
62
|
+
*/
|
|
63
|
+
static Environment standard();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @brief Create standard atmosphere with moderate random wind.
|
|
67
|
+
*
|
|
68
|
+
* Wind is sampled from normal distributions:
|
|
69
|
+
* - Horizontal components (x, y): σ = 10 m/s (~22 mph)
|
|
70
|
+
* - Vertical component (z): σ = 1 m/s
|
|
71
|
+
*
|
|
72
|
+
* Represents typical windy day conditions.
|
|
73
|
+
*
|
|
74
|
+
* @param seed Optional random seed for reproducibility
|
|
75
|
+
* @return Environment Standard conditions with moderate random wind
|
|
76
|
+
*/
|
|
77
|
+
static Environment standard_with_random_wind(std::optional<unsigned int> seed = std::nullopt);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @brief Create standard atmosphere with strong random wind.
|
|
81
|
+
*
|
|
82
|
+
* Wind is sampled from normal distributions:
|
|
83
|
+
* - Horizontal components (x, y): σ = 25 m/s (~56 mph)
|
|
84
|
+
* - Vertical component (z): σ = 5 m/s
|
|
85
|
+
*
|
|
86
|
+
* Represents tropical storm or gale force wind conditions.
|
|
87
|
+
*
|
|
88
|
+
* @param seed Optional random seed for reproducibility
|
|
89
|
+
* @return Environment Standard conditions with strong random wind
|
|
90
|
+
*/
|
|
91
|
+
static Environment standard_with_random_strong_wind(std::optional<unsigned int> seed = std::nullopt);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @brief Create standard atmosphere with extreme random wind.
|
|
95
|
+
*
|
|
96
|
+
* Wind is sampled from normal distributions:
|
|
97
|
+
* - Horizontal components (x, y): σ = 50 m/s (~112 mph)
|
|
98
|
+
* - Vertical component (z): σ = 10 m/s
|
|
99
|
+
*
|
|
100
|
+
* Represents Category 3 hurricane conditions.
|
|
101
|
+
*
|
|
102
|
+
* @param seed Optional random seed for reproducibility
|
|
103
|
+
* @return Environment Standard conditions with extreme random wind
|
|
104
|
+
*/
|
|
105
|
+
static Environment standard_with_random_extreme_wind(std::optional<unsigned int> seed = std::nullopt);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Create standard atmosphere with catastrophic random wind.
|
|
109
|
+
*
|
|
110
|
+
* Wind is sampled from normal distributions:
|
|
111
|
+
* - Horizontal components (x, y): σ = 100 m/s (~224 mph)
|
|
112
|
+
* - Vertical component (z): σ = 20 m/s
|
|
113
|
+
*
|
|
114
|
+
* Represents Category 5+ hurricane or strongest tornado conditions.
|
|
115
|
+
* Useful for stress testing numerical stability.
|
|
116
|
+
*
|
|
117
|
+
* @param seed Optional random seed for reproducibility
|
|
118
|
+
* @return Environment Standard conditions with catastrophic random wind
|
|
119
|
+
*/
|
|
120
|
+
static Environment standard_with_random_catastrophic_wind(std::optional<unsigned int> seed = std::nullopt);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#endif // BALLISTIC_SOLVE_ENVIRONMENT_HPP
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#ifndef BALLISTIC_SOLVE_PLATFORM_HPP
|
|
2
|
+
#define BALLISTIC_SOLVE_PLATFORM_HPP
|
|
3
|
+
|
|
4
|
+
#include <Eigen/Dense>
|
|
5
|
+
|
|
6
|
+
namespace ballistic_solve
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* @brief Launch platform properties for ballistic simulation.
|
|
10
|
+
*
|
|
11
|
+
* Represents the firing platform (e.g., ground position, moving vehicle, aircraft)
|
|
12
|
+
* including its position, velocity, and the muzzle velocity of the weapon system.
|
|
13
|
+
* The projectile's initial velocity is the vector sum of platform velocity and
|
|
14
|
+
* muzzle velocity in the launch direction.
|
|
15
|
+
*/
|
|
16
|
+
class Platform
|
|
17
|
+
{
|
|
18
|
+
public:
|
|
19
|
+
/// Position of the launch platform in 3D space (meters)
|
|
20
|
+
const Eigen::Vector3d position;
|
|
21
|
+
|
|
22
|
+
/// Velocity of the platform itself (m/s). For stationary platforms, this is zero.
|
|
23
|
+
const Eigen::Vector3d velocity;
|
|
24
|
+
|
|
25
|
+
/// Muzzle velocity magnitude (m/s). Speed of projectile relative to platform.
|
|
26
|
+
const double muzzle_velocity;
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* @brief Construct a launch platform.
|
|
31
|
+
*
|
|
32
|
+
* @param position 3D position vector in meters
|
|
33
|
+
* @param velocity 3D velocity vector in m/s (platform motion)
|
|
34
|
+
* @param muzzle_velocity Scalar muzzle velocity in m/s (projectile speed relative to platform)
|
|
35
|
+
*/
|
|
36
|
+
Platform(
|
|
37
|
+
const Eigen::Vector3d &position,
|
|
38
|
+
const Eigen::Vector3d &velocity,
|
|
39
|
+
const double muzzle_velocity);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#endif // BALLISTIC_SOLVE_PLATFORM_HPP
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#ifndef BALLISTIC_SOLVE_PROJECTILE_HPP
|
|
2
|
+
#define BALLISTIC_SOLVE_PROJECTILE_HPP
|
|
3
|
+
|
|
4
|
+
namespace ballistic_solve
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* @brief Physical properties of a projectile for ballistic simulation.
|
|
8
|
+
*
|
|
9
|
+
* Encapsulates the mass, cross-sectional area, and drag coefficient
|
|
10
|
+
* needed to compute aerodynamic forces during flight.
|
|
11
|
+
*/
|
|
12
|
+
class Projectile
|
|
13
|
+
{
|
|
14
|
+
public:
|
|
15
|
+
/// Mass of the projectile in kilograms
|
|
16
|
+
const double mass;
|
|
17
|
+
|
|
18
|
+
/// Cross-sectional area in square meters (perpendicular to velocity)
|
|
19
|
+
const double area;
|
|
20
|
+
|
|
21
|
+
/// Dimensionless drag coefficient (Cd). Typical values:
|
|
22
|
+
/// - Sphere: ~0.47
|
|
23
|
+
/// - Streamlined body: ~0.04
|
|
24
|
+
/// - Flat plate: ~1.28
|
|
25
|
+
const double drag_coefficient;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @brief Construct a projectile with specified properties.
|
|
29
|
+
*
|
|
30
|
+
* @param mass Mass in kilograms (default: 1 kg)
|
|
31
|
+
* @param area Cross-sectional area in square meters (default: 1 m²)
|
|
32
|
+
* @param drag_coefficient Dimensionless drag coefficient (default: 0.47, sphere)
|
|
33
|
+
*/
|
|
34
|
+
Projectile(
|
|
35
|
+
const double mass = 1.0,
|
|
36
|
+
const double area = 1.0,
|
|
37
|
+
const double drag_coefficient = 0.47);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#endif // BALLISTIC_SOLVE_PROJECTILE_HPP
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#ifndef BALLISTIC_SOLVE_SIMULATION_HPP
|
|
2
|
+
#define BALLISTIC_SOLVE_SIMULATION_HPP
|
|
3
|
+
|
|
4
|
+
#include "ballistic-solve/environment.hpp"
|
|
5
|
+
#include "ballistic-solve/projectile.hpp"
|
|
6
|
+
#include "ballistic-solve/trajectory.hpp"
|
|
7
|
+
#include "ballistic-solve/platform.hpp"
|
|
8
|
+
|
|
9
|
+
#include <Eigen/Dense>
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
namespace ballistic_solve
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* @brief Configuration for the adaptive ODE integrator.
|
|
16
|
+
*
|
|
17
|
+
* Controls the Dormand-Prince (DOPRI5) Runge-Kutta adaptive integration_options
|
|
18
|
+
* used for trajectory integration.
|
|
19
|
+
*/
|
|
20
|
+
struct IntegrationOptions
|
|
21
|
+
{
|
|
22
|
+
const double max_step = 1e3; ///< Maximum step size (seconds)
|
|
23
|
+
const double first_step = 1e-3; ///< Initial step size (seconds)
|
|
24
|
+
const double atol = 1e-6; ///< Absolute error tolerance
|
|
25
|
+
const double rtol = 1e-3; ///< Relative error tolerance
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @brief Convert spherical coordinates to 3D direction vector.
|
|
30
|
+
*
|
|
31
|
+
* @param angles Pair of (azimuth, elevation) angles in radians
|
|
32
|
+
* @return Eigen::Vector3d Unit direction vector
|
|
33
|
+
*/
|
|
34
|
+
Eigen::Vector3d to_direction(const std::pair<double, double> &angles);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @brief Convert 3D direction vector to spherical coordinates.
|
|
38
|
+
*
|
|
39
|
+
* @param direction Direction vector (need not be normalized)
|
|
40
|
+
* @return std::pair<double, double> (azimuth, elevation) in radians
|
|
41
|
+
*/
|
|
42
|
+
std::pair<double, double> to_angles(const Eigen::Vector3d &direction);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @brief Compute complete ballistic trajectory with recorded time steps.
|
|
46
|
+
*
|
|
47
|
+
* Simulates projectile motion under gravity, drag, and wind effects using
|
|
48
|
+
* adaptive Runge-Kutta integration. Records position at each integration step.
|
|
49
|
+
*
|
|
50
|
+
* @param environment Environmental conditions (gravity, air density, wind)
|
|
51
|
+
* @param projectile Projectile properties (mass, drag coefficient, area)
|
|
52
|
+
* @param platform Launch platform (position, velocity, muzzle velocity)
|
|
53
|
+
* @param direction Unit vector indicating launch direction
|
|
54
|
+
* @param time Simulation time (seconds)
|
|
55
|
+
* @param integration_options Integration parameters (step sizes, tolerances)
|
|
56
|
+
* @return Trajectory Complete trajectory with positions and times
|
|
57
|
+
*/
|
|
58
|
+
Trajectory compute_trajectory(
|
|
59
|
+
const Environment &environment,
|
|
60
|
+
const Projectile &projectile,
|
|
61
|
+
const Platform &platform,
|
|
62
|
+
const Eigen::Vector3d &direction,
|
|
63
|
+
const double time,
|
|
64
|
+
const IntegrationOptions &integration_options = IntegrationOptions{});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @brief Compute complete ballistic trajectory from launch angles.
|
|
68
|
+
*
|
|
69
|
+
* Convenience overload that accepts spherical coordinates instead of
|
|
70
|
+
* direction vector.
|
|
71
|
+
*
|
|
72
|
+
* @param environment Environmental conditions
|
|
73
|
+
* @param projectile Projectile properties
|
|
74
|
+
* @param platform Launch platform
|
|
75
|
+
* @param angles Pair of (azimuth, elevation) angles in radians
|
|
76
|
+
* @param time Simulation time (seconds)
|
|
77
|
+
* @param integration_options Integration parameters
|
|
78
|
+
* @return Trajectory Complete trajectory with positions and times
|
|
79
|
+
*/
|
|
80
|
+
Trajectory compute_trajectory(
|
|
81
|
+
const Environment &environment,
|
|
82
|
+
const Projectile &projectile,
|
|
83
|
+
const Platform &platform,
|
|
84
|
+
const std::pair<double, double> &angles,
|
|
85
|
+
const double time,
|
|
86
|
+
const IntegrationOptions &integration_options = IntegrationOptions{});
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @brief Compute final position only (no trajectory recording).
|
|
90
|
+
*
|
|
91
|
+
* More efficient than compute_trajectory when only the endpoint is needed.
|
|
92
|
+
* Uses the same physics simulation but doesn't record intermediate steps.
|
|
93
|
+
*
|
|
94
|
+
* @param environment Environmental conditions
|
|
95
|
+
* @param projectile Projectile properties
|
|
96
|
+
* @param platform Launch platform
|
|
97
|
+
* @param direction Unit vector indicating launch direction
|
|
98
|
+
* @param time Simulation time (seconds)
|
|
99
|
+
* @param integration_options Integration parameters
|
|
100
|
+
* @return Eigen::Vector3d Final position after given simulation time
|
|
101
|
+
*/
|
|
102
|
+
Eigen::Vector3d compute_point(
|
|
103
|
+
const Environment &environment,
|
|
104
|
+
const Projectile &projectile,
|
|
105
|
+
const Platform &platform,
|
|
106
|
+
const Eigen::Vector3d &direction,
|
|
107
|
+
const double time,
|
|
108
|
+
const IntegrationOptions &integration_options = IntegrationOptions{});
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @brief Compute final position only from launch angles.
|
|
112
|
+
*
|
|
113
|
+
* Convenience overload that accepts spherical coordinates.
|
|
114
|
+
*
|
|
115
|
+
* @param environment Environmental conditions
|
|
116
|
+
* @param projectile Projectile properties
|
|
117
|
+
* @param platform Launch platform
|
|
118
|
+
* @param angles Pair of (azimuth, elevation) angles in radians
|
|
119
|
+
* @param time Simulation time (seconds)
|
|
120
|
+
* @param integration_options Integration parameters
|
|
121
|
+
* @return Eigen::Vector3d Final position after given simulation time
|
|
122
|
+
*/
|
|
123
|
+
Eigen::Vector3d compute_point(
|
|
124
|
+
const Environment &environment,
|
|
125
|
+
const Projectile &projectile,
|
|
126
|
+
const Platform &platform,
|
|
127
|
+
const std::pair<double, double> &angles,
|
|
128
|
+
const double time,
|
|
129
|
+
const IntegrationOptions &integration_options = IntegrationOptions{});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#endif // BALLISTIC_SOLVE_SIMULATION_HPP
|