# Using pitch and yaw to set 3 dimensional rotation on an object. [closed]

Presume I have a yaw value. This yaw value represents a point on the circumference of a circle. This yaw value is absolute - meaning that it is locked to the y axis in a 3D world. Now, I have a pitch value; This pitch value is relative to the yaw, meaning that the yaw is set, and the pitch then follows an axis based on the direction the yaw is pointing to point to a point on the circumference of the relatively created circle. Theoretically, using pitch and yaw in this way, our pitch value can point towards any location in a sphere with a radius of both of the circles' radii.

Now, presume we want to take the pitch and yaw values, and pass them onto another object - put this one has a $x$, $y$, and $z$ rotation axis, and none are relative to each-other. How would we do this?

Some more info: distances around the circumference of the circles are measured in radians; It is assumed the circle's all have radii of 1.

My first attempt to solve this was to take the radians and convert them into $x$ and $y$ values. So I used the formula $x^2 + y^2 = r^2$, and used $x = \|cos(x)| * y$ to find the x rotation, and $\|sin(x)| * y$ to find the y rotation. The thought was that when working backwards like this, I could use the original x and y values from the formula and multiply them by $y$ to create a ratio as to how far each of these went; This sorta worked, but did not give the desired result.

## closed as unclear what you're asking by David K, José Carlos Santos, Antonios-Alexandros Robotis, user91500, Sahiba AroraAug 12 '17 at 15:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• What do you mean by "none are relative to each-other"? Do you mean the axes of the second object are not aligned with the "world" $y$-axis? If you want a mathematical formula, you'll have to figure out a much clearer picture of what you actually want to do. – David K Aug 12 '17 at 3:20
• The axis of the second ARE aligned to the world – Programah Aug 12 '17 at 3:24
• Then why are the pitch and yaw values in the second paragraph not just exactly the same ones you have in the first paragraph? – David K Aug 12 '17 at 3:28
• In the first one, the pitch was Dependant on the yaw. In the second, I introduced 3 independent axis – Programah Aug 12 '17 at 3:29
• There is no way to specify non-trivial rotations around multiple axes without specifying an order in which the rotations are applied. You can do the pitch first and then the yaw, which will make the pitch use the same world axis every time (its axis hasn't rotated yet) and the yaw use the same world axis every time (it's independent of the pitch). – David K Aug 12 '17 at 3:34

Indeed, you could find more useful the Tait–Bryan angles, which express directly the angles $\psi$, $\theta$ and $\phi$ as the yaw, pitch and roll operation.
This standard sequence is denoted as $z-y'-x''$, meaning you first rotate in the $z$ axis, then in the $y$ axis, then in the $x$ axis, always with respect to your plane (intrinsic rotation).
From the reference article, the transformation matrix is: $$R=Z_1 Y_2 X_3 = \begin{bmatrix} c_1 c_2 & c_1 s_2 s_3 - c_3 s_1 & s_1 s_3 + c_1 c_3 s_2 \\ c_2 s_1 & c_1 c_3 + s_1 s_2 s_3 & c_3 s_1 s_2 - c_1 s_3 \\ - s_2 & c_2 s_3 & c_2 c_3 \end{bmatrix}$$ where $1,2,3$ are the $\psi$, $\theta$ and $\phi$ are the yaw, pitch, roll angles; and $c,s$ are the $\cos,\sin$ functions.
from there you can easily check that $[1;0;0]$ transforms into $R[1;0;0]=[c_2;c_2s_1;-s_2]$, which is the correct value after a yaw-pitch (roll do not affect this vector).