# Simple vector problem, Weight vector components & sine and cosine of rotation?

I have the quadcopter in the photo below. It has rotate theta degrees about the -y axis. I want to get the x and z components in the local frame for the weight W which always points along the vertical downward. We simply have:

Wx = W sin(theta); Wz = W cos(theta);


Suppose that W = 4N and theta = 30 deg, then:

Wx = -4 * sin(-30) = 2N;   Wz = -4 * cos(-30) = -3.464N


The negative sign in the angle was put because the rotation is about the -y axis (counterclockwise).

Wz seems correct as it is pointing towards the negative local z axis but Wx is 2 which seems wrong because according to the diagram it is supposed to be -2 indicating that it point towards the negative local x axis.

What's wrong with my simple calculation?

EDIT:


Using rotation matrices, we have the following rotation matrix when pitching (rotating about y axis): This matrix is used to transform vectors from inertial frame Xn,Yn,Zn to local frame Xb,Yb,Zb. To find the components of the weight W, we can multiply this matrix by W. Doing so, we get the same result:

Wx = W sin(theta); Wz = W cos(theta);


You've written your equations as if the weight vector you drew was positive, but then used a negative weight vector in your calculation. If you flipped $W$ around in your drawing you'd get \begin{align} W_x &= -W \sin(\theta) \\ W_z &= W \cos(\theta) \end{align}
To expand, a more consistent approach is use to proper vector math. In this case you need apply a rotation to your weight vector (edited to correctly go from global to local frame) \begin{align} W_L &= [0~0~-mg]^T \\ R_{LG} &= \begin{bmatrix} \cos(-\theta) & 0 & -\sin(\theta) \\ 0 & 1 & 0 \\ \sin(-\theta) & 0 & \cos(\theta) \end{bmatrix} \\ W_L = R_{LG} W_G &= \begin{bmatrix} mg\sin(\theta) \\ 0 \\ mg \cos(\theta) \end{bmatrix} \end{align}