vibe coding an orbital mechanics simulation to try out claude code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

76 lines
2.4 KiB

#ifndef MANEUVER_H
#define MANEUVER_H
#include "physics.h"
#include "spacecraft.h"
struct SimulationState;
enum BurnDirection {
BURN_PROGRADE,
BURN_RETROGRADE,
BURN_NORMAL,
BURN_ANTINORMAL,
BURN_RADIAL_IN,
BURN_RADIAL_OUT,
BURN_CUSTOM
};
enum TriggerType {
TRIGGER_TIME,
TRIGGER_TRUE_ANOMALY
};
struct Maneuver {
char name[64];
int craft_index;
BurnDirection direction;
double delta_v;
TriggerType trigger_type;
double trigger_value;
bool executed;
double executed_time;
};
struct HohmannTransfer {
double dv1;
double dv2;
double transfer_time;
double true_anomaly_2;
};
// Direction calculation functions (local frame)
Vec3 calculate_prograde_dir(Vec3 local_velocity);
Vec3 calculate_retrograde_dir(Vec3 local_velocity);
Vec3 calculate_normal_dir(Vec3 local_position, Vec3 local_velocity);
Vec3 calculate_antinormal_dir(Vec3 local_position, Vec3 local_velocity);
Vec3 calculate_radial_in_dir(Vec3 local_position);
Vec3 calculate_radial_out_dir(Vec3 local_position);
Vec3 get_burn_direction_vector(BurnDirection direction, Vec3 local_pos, Vec3 local_vel);
// Burn application functions
void apply_impulsive_burn(Spacecraft* craft, BurnDirection direction, double delta_v);
void apply_custom_burn(Spacecraft* craft, Vec3 delta_v_local);
// Burn preview functions
OrbitalElements preview_burn_result(const Spacecraft* craft, BurnDirection direction, double delta_v, const SimulationState* sim);
// Burn optimization functions
HohmannTransfer calculate_hohmann_transfer(double r1, double r2, double central_mass);
// Maneuver information functions
const char* get_burn_direction_name(BurnDirection direction);
// Maneuver validation functions
bool validate_burn_parameters(const Spacecraft* craft, BurnDirection direction, double delta_v, double parent_mass);
// Maneuver execution functions
bool check_maneuver_trigger(Maneuver* maneuver, Spacecraft* craft, SimulationState* sim);
void execute_maneuver(Maneuver* maneuver, Spacecraft* craft, SimulationState* sim, double current_time);
// Maneuver management functions
Maneuver create_maneuver(const char* name, int craft_index, BurnDirection direction, double delta_v, TriggerType trigger_type, double trigger_value);
int add_maneuver_to_simulation(SimulationState* sim, Maneuver* maneuver);
bool remove_maneuver_by_index(SimulationState* sim, int index);
#endif