-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preliminary Interplanetary Transfers (#2)
- Loading branch information
Showing
46 changed files
with
1,135 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,3 +134,6 @@ dmypy.json | |
|
||
# VS Code | ||
.vscode/ | ||
|
||
# Versioning from setuptools_scm | ||
src/trajectorize/_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Trajectorize | ||
Delta v estimator | ||
*/ | ||
|
||
#ifndef DELTA_V_ESTIMATE_H | ||
#define DELTA_V_ESTIMATE_H | ||
|
||
#include "kerbol_system_types.h" | ||
#include "vec_math_types.h" | ||
|
||
double delta_v_req(Body body, double excess_velocity, double periapsis); | ||
|
||
#endif // DELTA_V_ESTIMATE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "orbit_math.h" | ||
#include "vec_math.h" | ||
|
||
#ifndef _ROTATIONS_H | ||
#define _ROTATIONS_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Trajectorize | ||
Transfer Orbit Calculator | ||
Header file for functions to calculate transfer orbits between two bodies in the Kerbol system. | ||
*/ | ||
|
||
#ifndef TRANSFER_ORBIT_H | ||
#define TRANSFER_ORBIT_H | ||
|
||
#include "keplerian_element_types.h" | ||
#include "kerbol_system_types.h" | ||
#include "vec_math_types.h" | ||
|
||
KeplerianElements planetary_transfer_orbit(Body body1, Body body2, double t1, double t2); | ||
Vector3 excess_velocity_at_body(Body body, KeplerianElements transfer_orbit, double ut); | ||
|
||
#endif // TRANSFER_ORBIT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,44 @@ | ||
[build-system] | ||
requires = ["setuptools>=61", "wheel", "cffi>=1.15.0"] | ||
requires = [ | ||
"setuptools>=64", | ||
"wheel", | ||
"cffi>=1.15.0", | ||
"setuptools_scm[toml]>=6.0", | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "trajectorize" | ||
description = "KSP Trajectory Optimization" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = { text = "LGPLv3" } | ||
authors = [{ name = "Mingde Yin", email = "[email protected]" }] | ||
maintainers = [{ name = "Mingde Yin", email = "[email protected]" }] | ||
keywords = ["kerbal space program", "trajectory", "optimization"] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: C", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Topic :: Scientific/Engineering", | ||
"Topic :: Scientific/Engineering :: Mathematics", | ||
"Topic :: Scientific/Engineering :: Physics", | ||
"Topic :: Scientific/Engineering :: Astronomy", | ||
] | ||
dependencies = ["numpy >= 1.23.0", "matplotlib >= 3.4.0", "cffi >= 1.15.0"] | ||
dynamic = ["version"] | ||
|
||
[project.urls] | ||
homepage = "https://github.com/itchono/trajectorize" | ||
|
||
[tool.setuptools.packages.find] | ||
include = ["trajectorize"] | ||
where = ["src"] | ||
|
||
[tool.setuptools_scm] | ||
write_to = "src/trajectorize/_version.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# Make sure trajectorize is installed | ||
# Temporarily set env to make matplotlib use Agg backend | ||
export MPLBACKEND=Agg | ||
|
||
# Generate plots | ||
python -m trajectorize.demos.orbit | ||
python -m trajectorize.demos.kerbin_duna_transfer | ||
python -m trajectorize.demos.kerbin_duna_porkchop | ||
python -m trajectorize.demos.kerbol_system_anim --save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from importlib.metadata import version, PackageNotFoundError | ||
|
||
try: | ||
__version__ = version("trajectorize") | ||
except PackageNotFoundError: | ||
__version__ = "unknown version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
|
||
from trajectorize._c_extension import ffi, lib | ||
|
||
|
||
def process_sva_buffer(sva_struct, length: int) -> np.ndarray: | ||
# Process memory buffer | ||
# Format: [x, y, z, vx, vy, vz, t] x n | ||
arr = np.frombuffer(ffi.buffer(sva_struct.mem_buffer, 7 * | ||
8 * length), dtype=np.float64) | ||
arr.shape = (length, 7) | ||
copied_arr = np.copy(arr) | ||
|
||
# Free memory | ||
lib.free_StateVectorArray(sva_struct) | ||
|
||
return copied_arr |
Oops, something went wrong.