# Modelling a drone in 3D: finding the z component of the thrust vector knowing pitch (about x) and roll (about y) angles.

I have been trying to create the model of a drone for fun and when calculating the linear dynamics I need to find out the Z component of the thrust vector.

Basically, in 3D space the thrust vector is always perpendicular to my drone, hence its angle and therefore z component changes with the pitch and the roll of the drone. Pitch is the angle about the x axis and roll is the angle about the y axis with $$0$$ degrees being the vector pointing straight up.

I also know the total magnitude of the thrust vector, basically the total thrust generated by my drone. From there I can easily get the thrust vectors' components in the x and y directions by multiplying the vector's magnitude to, respectively, sin(roll) and sin(pitch).

What I have been doing until now is then using the magnitude to write that: $$M^2=X^2+Y^2+Z^2$$ with M being the magnitude and X, Y Z the components of the thrust vector. From this I rewrote,

$$Z=\sqrt{M^2-X^2-Y^2}$$

Again here: $$X=sin(roll)*M$$ and $$Y=sin(pitch)*M$$ with roll the angle about the y axis and pitch the angle about the X axis.

The problem is that this fails in a lot of cases as $$M^2-X^2-Y^2$$ becomes negative. I am sure I did something basic pretty wrong here but I cannot get my head around it, I would greatly appreciate your help if anyone knows what I am doing wrong.

Thank you!

• Some inspiration for finding the right equations for X and Y can be found here. – Jens Oct 19 '18 at 16:43

A positive pitch creates an angle between Z and the thrust vector (looking in the 2D ZY coordinate system), the z coordinate of this vector then becomes: $$Z=M*cos(Pitch)$$
$$Z=M*cos(Roll)$$
So eventually, putting this together, we get: $$Z=M*cos(Pitch)*cos(Roll)$$