Public Group

# Direct X: D3DXMatrixRotationAxis?

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

## Recommended Posts

Hi Im a begginer, and am wanting, just to start with, to roll a ball around the screen. Im using direct X (i recently did some online tutorials on it). Should I use D3DXMatrixRotationAxis? If so, how? What would I put in the D3DXVECTOR3 to make it work? Or should I be using D3DXMatrixRotationQuaternion? Or something else? Thanks in advice Andy

##### Share on other sites
Quaternions and matrices are, as far as i know, pretty different.

Are you trying to move a 3D ball? or a 2D ball. If 3D maybe this is a bit ambitious for your first project.

But more to the point, i personaly would play around with matrices for the X,Y and Z axis all at once then concatenating tehm for teh transformation to teh ball.

ace

##### Share on other sites
Thanks Ace

Ive tried using D3DXMatrixRotationZ & D3DXMatrixRotationX. At first, it seemed like it worked, but as I messed around with my ball a bit more, sometimes the ball wasn't rotating in the right direction. It especially seemed so when I moved the ball left and right (meaning the ball would be ROTATING on the Z axis, and MOVING left and right ALONG the X axis). Here is my code.
Here is the relevant bits of code for rotating the ball assuming this is the bit where my problem lies). Any ideas for what ive done wrong?

//Work out how to roll the ball over the X and Z axisD3DXMatrixRotationZ(&matRotateZ, D3DXToRadian(m_rAngleZ));D3DXMatrixRotationX(&matRotateX, D3DXToRadian(m_rAngleX));//Multiply the rotation matrices, and then the matrix that physically moves the ballD3DXMatrixMultiply(&matBallRoll, &matRotateZ, &matRotateX);D3DXMatrixMultiply(&matBall, &matBallRoll, &matBallMove);//Render the ballm_pD3DDevice->SetTransform(D3DTS_WORLD, &matBall);m_dwTotalPolygons += m_pSphere->Render();

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631748
• Total Posts
3002030
×