0
\$\begingroup\$

I have an assignment where they ask me to calculate Vector Right and Vector Up, it's for a camera creation using C++ and DirectX. For the Vector Right, they specify I should use 90-yaw, so I got:

\$ V_{Right} = \{cos(90-yaw), 0, sin(90-yaw)\}. \$

For Vector Up, I'm still not sure how should I calculate it using yaw and pitch. My initial thought was to set it like this:

\$ V_{Up} = \{cos(yaw) * cos(pitch), sin(pitch), sin(yaw) * cos(pitch)\}. \$

However, I think I'm confusing it with the Forward Vector. I know I can get a rotation matrix and use also cross products to obtain them, but they specify that I should use yaw and pitch and I'm kinda lost here since cannot find a clear answer with the setup I'm mentioning.

Could you help me to find the Up, Right and Direction vectors? (I suppose the direction is the Forward one.)

Any help would be useful!

\$\endgroup\$
1

1 Answer 1

1
\$\begingroup\$

You don't specify your reference frame, but based on your $$V_{Right} = \lbrace \cos(90−yaw),0,\sin(90−yaw) \rbrace $$ I'm guessing it's {forward, up, right} with yaw about the y-axis and pitch about the z-axis. To get the yaw rotation matrix, consider rotation in the x-z plane:

$$ Rot_{y} (yaw) = \begin{bmatrix} \cos (yaw) & 0 & \sin (yaw) \\ 0 & 1 & 0 \\ - \sin (yaw) & 0 & \cos (yaw) \end{bmatrix} $$

The pitch rotation matrix is in the x-y plane: $$ Rot_{z} (pitch) = \begin{bmatrix} \cos (pitch) & - \sin (pitch) & 0 \\ \sin (pitch) & \cos (pitch) & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} $$

You should apply pitch first, then yaw, so the final rotation matrix is

$$ Rot_y (yaw) \cdot Rot_z (pitch) $$

which you can work out for yourself. To get your forward, up, right vectors after rotation, multiply your basis vectors (e.g. forward is [1, 0, 0]) by the rotation matrix.

If you want to use (90 deg-yaw), remember that the cosine of an angle is the sine of its complement, or

$$ \cos (\theta) = \sin ( 90^{\circ} - \theta ) $$

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .