Initial project setup: Rust/WASM solar system simulator with SvelteKit frontend
- Rust workspace with 4 crates: orbital-mechanics, mass-driver-core, mass-driver-wasm, mass-driver-backend - Keplerian orbital mechanics engine with JPL elements for 14 bodies (Sun, 8 planets, Pluto, Ceres, Europa, Titan, Ganymede) - Kepler equation solver and orbital position computation compiled to WASM - SvelteKit frontend with Tailwind CSS, Canvas2D renderer showing animated solar system - Orbit ellipses, planet dots with labels, Sun glow, grid, scale bar, pan/zoom controls - Time controls (play/pause, 5 speed levels, date picker) driving live simulation - 2D/3D view toggle (3D placeholder for Threlte integration) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
crates/mass-driver-core/Cargo.toml
Normal file
13
crates/mass-driver-core/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "mass-driver-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
orbital-mechanics = { path = "../orbital-mechanics" }
|
||||
nalgebra = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
petgraph = "0.8"
|
||||
ordered-float = "5"
|
||||
rmp-serde = "1"
|
||||
2
crates/mass-driver-core/src/lib.rs
Normal file
2
crates/mass-driver-core/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod station;
|
||||
pub mod route;
|
||||
24
crates/mass-driver-core/src/route.rs
Normal file
24
crates/mass-driver-core/src/route.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A single leg of a route between two stations.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct RouteLeg {
|
||||
pub from_station: usize,
|
||||
pub to_station: usize,
|
||||
/// Departure week index (0 = first week of simulation)
|
||||
pub departure_week: u32,
|
||||
/// Arrival week index
|
||||
pub arrival_week: u32,
|
||||
/// Weeks spent waiting at departure station before this leg
|
||||
pub wait_weeks: u32,
|
||||
}
|
||||
|
||||
/// The result of a route computation.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct RouteResult {
|
||||
pub legs: Vec<RouteLeg>,
|
||||
/// Total elapsed time in weeks from departure to final arrival
|
||||
pub total_time_weeks: u32,
|
||||
/// The week index when the package departs the origin
|
||||
pub departure_week: u32,
|
||||
}
|
||||
44
crates/mass-driver-core/src/station.rs
Normal file
44
crates/mass-driver-core/src/station.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// How a station is placed in the solar system.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum StationPlacement {
|
||||
/// Station in heliocentric orbit
|
||||
SolarOrbit {
|
||||
a: f64, // Semi-major axis (AU)
|
||||
e: f64, // Eccentricity
|
||||
i: f64, // Inclination (degrees)
|
||||
omega: f64, // Longitude of ascending node (degrees)
|
||||
w: f64, // Argument of perihelion (degrees)
|
||||
m0: f64, // Mean anomaly at epoch (degrees)
|
||||
},
|
||||
/// Station in orbit around a planet
|
||||
PlanetaryOrbit {
|
||||
parent_body_id: usize,
|
||||
altitude_km: f64,
|
||||
inclination: f64,
|
||||
},
|
||||
/// Station at a Lagrange point
|
||||
LagrangePoint {
|
||||
primary_body_id: usize, // e.g., Sun
|
||||
secondary_body_id: usize, // e.g., Earth
|
||||
point: LagrangePointId,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum LagrangePointId {
|
||||
L1,
|
||||
L2,
|
||||
L3,
|
||||
L4,
|
||||
L5,
|
||||
}
|
||||
|
||||
/// A mass driver relay station.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Station {
|
||||
pub id: usize,
|
||||
pub name: String,
|
||||
pub placement: StationPlacement,
|
||||
}
|
||||
Reference in New Issue
Block a user