# How to Create an Angle from a Yaw/Pitch matrix

This topic is 1564 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i am using this code which takes the Yaw and Pitch angles of the mouse with directx input

D3DXMatrixRotationYawPitchRoll(&matYawPitch, Yaw, 0.0f, Pitch);

what i want todo is fire bullets in the direction the matrix is set to, i am using std::list for the container type

##### Share on other sites

Multiply a forward vector ([0,0,1]) by the resulting matrix (matYawPitch).

Normalize for safety (but it should be normalized already).

The vector is the direction of the bullets.

L. Spiro

##### Share on other sites

I didnt know you could multiply a vector with a matrix?

##### Share on other sites

I didnt know you could multiply a vector with a matrix?

There are several D3DX functions which use both vectors and matrices. In particular, D3DXVec2[3,4]Transformxxx applies a matrix to a vector. There are also functions such as D3DXVec3Project and ..Unproject which take multiple vectors and matrices.

In particular, for graphics work, multiplying a vector by a matrix is a very common math process. You don't see it explicitly as much in D3DX9 because a large portion of the conversion of positions and directions (vectors) by matrices is done in the GPU. But that's the base process for rendering vertices (vectors) using the world, view and projection matrices.

Edited by Buckeye

##### Share on other sites

wouldnt i need to use D3DXVec3TransformNormal, as i am looking to get a direction from the matrix?

##### Share on other sites

wouldnt i need to use D3DXVec3TransformNormal, as i am looking to get a direction from the matrix?

Yes.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634111
• Total Posts
3015563
×