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.
 
 
 
 
 

38 lines
795 B

#ifndef PHYSICS_H
#define PHYSICS_H
// Forward declaration
struct CelestialBody;
// 3D Vector
struct Vec3 {
double x, y, z;
};
// Gravitational constant (m^3 kg^-1 s^-2)
const double G = 6.67430e-11;
// Vector math functions
Vec3 vec3_add(Vec3 a, Vec3 b);
Vec3 vec3_sub(Vec3 a, Vec3 b);
Vec3 vec3_cross(Vec3 a, Vec3 b);
Vec3 vec3_scale(Vec3 v, double s);
double vec3_magnitude(Vec3 v);
double vec3_distance(Vec3 a, Vec3 b);
Vec3 vec3_normalize(Vec3 v);
// Physics functions
Vec3 calculate_acceleration(Vec3 force, double mass);
// Forward declaration for RK4 context
struct SimulationState;
struct AccelerationContext {
SimulationState* sim;
CelestialBody* current_body;
int body_index;
};
void rk4_step(CelestialBody* body, AccelerationContext* ctx, double dt);
#endif