#### Archived

This topic is now archived and is closed to further replies.

# D3DX Matrix math screwed, or mine?

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

## Recommended Posts

Hi, I''m having some troubles with my matrix math using D3DX. I hope somebody is willing and able to help me. Ok, here is the setup: I''ve got a matrix. It represents the position, rotation and scaling (duh) in a world. I can rotate/translate/scale it using the DX functions. For example, the translation code is: D3DXMATRIX matTmp; D3DXMatrixTranslation(&matTmp, x, y, z); m_Mat = matTmp * m_Mat; m_Mat is the matrix I''m talking about (which is in its initial state, an identity matrix). Now I want to shoot a projectile in the same direction the "player" is looking at. I copy the matrix and calculate a vector for the projectile, this way: D3DXVECTOR3 vec1, vec2, vec3; D3DXMATRIX matTmp; D3DXMatrixIdentity(&matTmp); D3DXVec3TransformCoord(&vec1, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), &m_Mat); D3DXVec3TransformCoord(&vec2, &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &matTmp); D3DXVec3Subtract(&vec3, &vec1, &vec2); m_Vect = vec3; I thought this should give me a rotated (by the matrix) vector. Actually, it does, but its rotation is twice of that its supposed to be. For example: 90 degrees on the x axis instead of 45 degrees like the original matrix. I guess I''m doing something wrong, but I don''t know what. As far as I know, this should work, but it doesn''t. Thx, Steve_-

##### Share on other sites
Ok,

I figured out the problem myself.

I was using the matrix (which is already rotated ''n stuff) and a rotated vector. ((DUH)^10)

Sorry for this.

Steve_-

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011313
• ### Who's Online (See full list)

There are no registered users currently online

×