The simulator applies the standard newtonian gravity formulation.
Assuming we are only interested in the force acting on the rocket, and that the center of the Earth is in the origin, the gravitational force is:
- G : gravity constant
- m : mass of the rocket
- M_e : mass of Earth
- r : position vector of the Rocket w.r.t. the origin
# Gravitational force
F_g = (- p * G * M_e * m)/(np.linalg.norm(p)**3)
The drag force is assumed to be a quadratic function of velocity, formulated as:
- v hat : normalized velocity vector
- C_d : drag coefficient
- rho : air density at current altitude
- |v|: velocity magnitude
If the velocity is 0 the formula is skipped and drag force is also set to 0.
# Compute the drag force
abs_v = np.linalg.norm(v)
if abs_v != 0:
normalized_vel = v / abs_v
F_d = -normalized_vel * drag_force(np.linalg.norm(p), abs_v)
else:
F_d = np.array([0, 0])
The thrust force is the direction of the rocket body orientation and depends on the fuel consumption rate and gas exhaust velocity.
# Compute the thrust force
if m_f > 0 and engine_active:
F_t = np.array([np.sin(alpha), np.cos(alpha)]) * (r_f * v_e)
F_t = rot_mat(gimbal_angle) @ F_t
else:
F_t = np.array([0, 0])