#### Archived

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

# How to rotate a triangle around 2 axi!?

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

## Recommended Posts

I am very new to DirectX Programming and I am just getting around to the rotating part. But what I wish to do now is not only rotate a triangle around the x axis but also simultaneously around the y - in otherwords, x and y together rotating. Here''s the code I have so far. Thanx in advance! static int iRotationDegrees = 0; //Setup a matrix to rotate iRotationDegrees degrees around the Y axis D3DXMATRIX matRotation; D3DXMatrixRotationZ(&matRotation, D3DXToRadian(iRotationDegrees)); //Set that matrix to the world transformation g_pDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matRotation); //Increment the degree of rotation iRotationDegrees++; if (iRotationDegrees == 360) iRotationDegrees = 0; From, The NeWbIe!

##### Share on other sites
//Setup a matrix to rotate iRotationDegrees degrees around the Y axis
D3DXMATRIX matRotation;

D3DXMATRIX matYRotation;
D3DXMatrixRotationY( &matYRotation, D3DXToRadian( iRotationDegrees ) );

matYRotation *= matRotation;

// END MY CODE

This is known as concatenation - which is more or less just multiplying one matrix by another to produce a matrix that has the properties of both.

You might also want to look into D3DXMatrixRotationAxis.

Tom L

##### Share on other sites
Thank you SOOO much! It worked and now I am soo totally excited - yeah! Thanx again!

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

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

• Total Topics
631757
• Total Posts
3002131
×