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.
 
 
 
 
 

30 lines
761 B

#ifndef PHYSICS_H
#define PHYSICS_H
// 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);
double vec3_dot(Vec3 a, Vec3 b);
// Physics functions
Vec3 calculate_acceleration(Vec3 force, double mass);
// Physics integration functions
void rk4_step(Vec3* position, Vec3* velocity, double dt,
double body_mass, double parent_mass);
Vec3 evaluate_acceleration(Vec3 relative_pos, double body_mass, double parent_mass);
#endif