Add gravity and thrust force
This commit is contained in:
parent
8f4d61f820
commit
8904c223cb
4 changed files with 67 additions and 3 deletions
20
cixdof/forces.c
Normal file
20
cixdof/forces.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#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)};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue