#### Archived

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

# 90 x 90 y 90 z

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

## Recommended Posts

i know there something wrong with this one,i''m a bit new to 3d. i rotate my object by 90 about the x-axis, then by 90 about the y-axis, finally 90 about the z-axis. if i reset my values according to the inverser order of how i placed it(z,y,x), it returns to back to it''s original position. But if i reset in a different manner,for example (x,y,z) order i don''t seem to arrive at the correct origin anymore. here is a sample code on how i assign my rotation:


void ObjectHandle::UpdateAngles(int axis, FLOAT offset1, FLOAT offset2)
{
float angle = 0.0f;
D3DXVECTOR3 taxis = D3DXVECTOR3(0.0f, 0.0f, 0.0f);;
D3DXQUATERNION tempQuat;
D3DXQuaternionIdentity(&tempQuat);

switch(axis)
{
case X	:	m_properties.angles.x += offset1;

angle = (float)sqrt(  pow(offset1,2) + pow(0.0f,2) + pow(0.0f,2));
D3DXVec3Normalize(&taxis, &D3DXVECTOR3(1.0f,0.0f,0.0f));
D3DXQuaternionRotationAxis(&tempQuat, &taxis, offset1);
break;
case Y	:	m_properties.angles.y += offset1;

angle = (float)sqrt(  pow(0.0f,2)+ pow(offset1,2) + pow(0.0f,2));
D3DXVec3Normalize(&taxis, &D3DXVECTOR3(0.0f,1.0f,0.0f));
D3DXQuaternionRotationAxis(&tempQuat, &taxis, offset1);

break;
case Z	:	m_properties.angles.z += offset1;

angle = (float)sqrt(  pow(0.0f,2)+ pow(0.0f,2) + pow(offset1,2));
D3DXVec3Normalize(&taxis, &D3DXVECTOR3(0.0f,0.0f,1.0f));
D3DXQuaternionRotationAxis(&tempQuat, &taxis, offset1);

break;
case XY	:	m_properties.angles.x += offset1;
m_properties.angles.y += offset2;

angle = (float)sqrt(  pow(offset1,2)+ pow(offset2,2) + pow(0.0f,2));
D3DXVec3Normalize(&taxis, &D3DXVECTOR3(offset1,offset2,0.0f));
D3DXQuaternionRotationAxis(&tempQuat, &taxis, angle);

break;
case YZ	:	m_properties.angles.y += offset1;
m_properties.angles.z += offset2;

angle = (float)sqrt(  pow(0.0f,2)+ pow(offset1,2) + pow(offset2,2));
D3DXVec3Normalize(&taxis, &D3DXVECTOR3(0.0f,offset1, offset2));
D3DXQuaternionRotationAxis(&tempQuat, &taxis, angle);

break;
case XZ	:	m_properties.angles.x += offset1;
m_properties.angles.z += offset2;

angle = (float)sqrt(  pow(offset1,2)+ pow(0.0f,2) + pow(offset2,2));
D3DXVec3Normalize(&taxis, &D3DXVECTOR3(offset1,0.0f, offset2));
D3DXQuaternionRotationAxis(&tempQuat, &taxis, angle);

break;
}

m_transform.Quat *= tempQuat;
}


hope you guys could help thanks..

##### Share on other sites
Of course, that''s normal. Did you expect the two rotation orders to give the same result? Maybe we can help you if you tell us why you want them to give the same result.

My site

##### Share on other sites
i''m trying to create an application just like studio max, inputing values, in three axis, then returning to the origin if reset to zero happens.

##### Share on other sites
If you want to reset the object''s orientation, why don''t you just reset your quaternion to identity. i.e.
D3DXQuaternionIdentity(&m_transform.Quat);

My site

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 10
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632647
• Total Posts
3007640
• ### Who's Online (See full list)

There are no registered users currently online

×