Browse Source
- Move RendezvousState and RendezvousTarget from rendezvous_types.h to orbital_objects.h - Remove rendezvous_types.h entirely - Simplify rendezvous.h to depend on orbital_objects.h - Delete spacecraft.h and spacecraft.cpp (consolidated into orbital_objects.h) - Update all include paths across codebase - All tests pass (4 pre-existing failures unchanged)main
23 changed files with 183 additions and 194 deletions
@ -0,0 +1,106 @@
|
||||
#ifndef ORBITAL_OBJECTS_H |
||||
#define ORBITAL_OBJECTS_H |
||||
|
||||
#include "physics.h" |
||||
#include "orbital_mechanics.h" |
||||
|
||||
// Forward declarations
|
||||
struct SimulationState; |
||||
|
||||
// ============================================================================
|
||||
// Rendezvous Types
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Rendezvous state machine |
||||
* |
||||
* States: |
||||
* - NONE: No rendezvous active |
||||
* - PLANNING: Target selected, approaching |
||||
* - APPROACHING: Closing in on target |
||||
* - MATCHING: Velocity matching phase |
||||
* - COMPLETE: Rendezvous successful |
||||
* - FAILED: Rendezvous failed |
||||
*/ |
||||
typedef enum { |
||||
RENDEZVOUS_NONE, |
||||
RENDEZVOUS_PLANNING, |
||||
RENDEZVOUS_APPROACHING, |
||||
RENDEZVOUS_MATCHING, |
||||
RENDEZVOUS_COMPLETE, |
||||
RENDEZVOUS_FAILED |
||||
} RendezvousState; |
||||
|
||||
/**
|
||||
* Rendezvous target structure |
||||
* |
||||
* Tracks the active rendezvous target and state for a spacecraft |
||||
*/ |
||||
typedef struct { |
||||
int target_index; // Index of target spacecraft/body
|
||||
int state; // RendezvousState
|
||||
double approach_distance; // Distance to start approach phase (m)
|
||||
double capture_distance; // Distance for capture (m)
|
||||
double max_relative_velocity; // Max closing speed for capture (m/s)
|
||||
double cw_linearization_time; // Last time CW equations were linearized (s)
|
||||
bool is_spacecraft_target; // True if target is spacecraft, false if body
|
||||
} RendezvousTarget; |
||||
|
||||
// ============================================================================
|
||||
// Celestial Body Structure
|
||||
|
||||
/**
|
||||
* Celestial Body Structure |
||||
* |
||||
* Represents a planet, star, moon, or other gravitational body |
||||
* in the simulation. Supports hierarchical orbital mechanics with |
||||
* parent-child relationships and sphere of influence calculations. |
||||
*/ |
||||
struct CelestialBody { |
||||
char name[64]; |
||||
double mass; // kg
|
||||
double radius; // meters
|
||||
int parent_index; // index of gravitational parent (-1 for root body like Sun)
|
||||
float color[3]; // RGB color for rendering
|
||||
|
||||
// Orbital elements from config (Keplerian elements)
|
||||
OrbitalElements orbit; |
||||
|
||||
// Global frame (from origin)
|
||||
Vec3 global_position; // meters from origin
|
||||
Vec3 global_velocity; // m/s
|
||||
|
||||
// Local frame (relative to parent)
|
||||
Vec3 local_position; // meters from parent
|
||||
Vec3 local_velocity; // m/s relative to parent
|
||||
|
||||
double soi_radius; // sphere of influence radius (meters)
|
||||
}; |
||||
|
||||
/**
|
||||
* Spacecraft Structure |
||||
* |
||||
* Represents a spacecraft or probe in the simulation. |
||||
* Supports orbital mechanics, maneuvers, and rendezvous operations. |
||||
*/ |
||||
struct Spacecraft { |
||||
char name[64]; |
||||
double mass; |
||||
int parent_index; |
||||
|
||||
// Orbital elements from config
|
||||
OrbitalElements orbit; |
||||
|
||||
// Global frame (from origin)
|
||||
Vec3 global_position; |
||||
Vec3 global_velocity; |
||||
|
||||
// Local frame (relative to parent)
|
||||
Vec3 local_position; |
||||
Vec3 local_velocity; |
||||
|
||||
// Rendezvous support
|
||||
RendezvousTarget rendezvous_target; // Active rendezvous target (if any)
|
||||
}; |
||||
|
||||
#endif // ORBITAL_OBJECTS_H
|
||||
@ -1,5 +0,0 @@
|
||||
#include "spacecraft.h" |
||||
#include "simulation.h" |
||||
#include <cstdio> |
||||
#include <cstring> |
||||
#include <cmath> |
||||
@ -1,28 +0,0 @@
|
||||
#ifndef SPACECRAFT_H |
||||
#define SPACECRAFT_H |
||||
|
||||
#include "physics.h" |
||||
#include "orbital_mechanics.h" |
||||
#include "simulation.h" |
||||
|
||||
struct Spacecraft { |
||||
char name[64]; |
||||
double mass; |
||||
int parent_index; |
||||
|
||||
// Orbital elements from config
|
||||
OrbitalElements orbit; |
||||
|
||||
// Global frame (from origin)
|
||||
Vec3 global_position; |
||||
Vec3 global_velocity; |
||||
|
||||
// Local frame (relative to parent)
|
||||
Vec3 local_position; |
||||
Vec3 local_velocity; |
||||
|
||||
// Rendezvous support
|
||||
RendezvousTarget rendezvous_target; // Active rendezvous target (if any)
|
||||
}; |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue