2026-11-01 23:38:25 -05:00
|
|
|
#ifndef FORCES_H
|
|
|
|
|
#define FORCES_H
|
|
|
|
|
|
|
|
|
|
#include "../mathprimitives/mathprimitives.h"
|
|
|
|
|
#include "drone.h"
|
|
|
|
|
|
|
|
|
|
static const double G = 9.80665;
|
|
|
|
|
|
|
|
|
|
static inline struct Vec3 gravity(double mass) {
|
|
|
|
|
return (struct Vec3){0, 0, mass * G};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ThrustAndMoment {
|
|
|
|
|
struct Vec3 thrust_inertial;
|
|
|
|
|
struct Vec3 moment_body;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ThrustAndMoment thrust(struct Quat attitude, struct Propeller *p);
|
|
|
|
|
|
2026-11-03 22:38:36 -05:00
|
|
|
static inline struct Vec3 drag(double drag_coefficient, struct Vec3 velocity) {
|
|
|
|
|
return (struct Vec3){
|
|
|
|
|
-velocity.x * drag_coefficient,
|
|
|
|
|
-velocity.y * drag_coefficient,
|
|
|
|
|
-velocity.z * drag_coefficient,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-01 23:38:25 -05:00
|
|
|
#endif
|