#include "forces.h" struct ThrustAndMoment thrust(struct Quat attitude, struct Propeller *p) { struct Vec3 body_thrust = {0.0, 0.0, -p->thrust_coefficient * p->angular_velocity * p->angular_velocity}; struct Vec3 inertial_thrust = quat_apply(attitude, body_thrust); // Pitching/rolling moment induced by thrust force struct Vec3 force_moment = vec3_cross(p->x_cg2p_b, body_thrust); // Yaw moment induced by rotation of propeller struct Vec3 drag_moment = {0.0, 0.0, (double)p->direction * p->moment_coefficient * p->angular_velocity * p->angular_velocity}; return (struct ThrustAndMoment){inertial_thrust, vec3_add(force_moment, drag_moment)}; }