# Rotation

When we rotate an object about an axiz parallel to co-ordinate axis the original co-ordinates of object changes slightly (where they should not) . How we can solve this problem.
###### Who is Participating?

Commented:
Hmm what you do is to rotate the rectangle around it's own axis then you translate it to the coordinate you want.

The example is in VB but since it's D3DX it's the same except for syntax quirks.

'Rotate
D3DXMatrixRotationX myMatX, -0.05 'Rotate
'Multiplay with the view
D3DXMatrixMultiply ourMatView, myMatX, ourMatView
'Do the transformation
ourD3DDevice.SetTransform D3DTS_VIEW, ourMatView

/Joachim
0

Commented:
That is a confusing question.  When you rotate an object its coordinates are going to change.  So I don't understand what you mean by that.

Also, what do you mean by "an axiz parallel to co-ordinate axis"?
0

Author Commented:
for example I rotate a rectangle about itself (about an axis parallel to x-axis)by 360 degrees. That means original rectangle should be restored. But this does not happen. What procedure I have adopted is to translate the rectangle so its centre on x-axis and then rotate it and translate it back. I generated a composite matrix and transformed the triangle.
0

Commented:
Sana, ideally, your concept should work, but in reality, whenever you deal with a decimal value (such as PI and division), it's rare it'll ever return to the original value.

Unless, you're rotating in all three directions, I usually apply my rotation from my origin.  And whenever the angle crosses 360 degree, I just minus or mod the value by 360.  Whenever you add onto a existing value, you're bound to run into some offset value.
0

Author Commented:
Joachim
I have tried to rotate the view matrice but things disappear from the screen. What can be problem.
0

Commented:
To solve this problem, I made an
array of cos, sin tables. I then
kept a copy of the untransformed shape
and calculated the rotation to a transformed
shape. When I changed theta, the rotation
of the shape changed. But the rotations where
kept constant because I used the untransformed
shape with the cos, sin tables. This eleminated
the decimal error you normally experience.
This is not however, an inefficient method. Your
rotations are limited to your tables, and there is
something better out there.

0

Commented:
Can't see a problem with my code. The thing you can do is to multiply in the wrong order. That gives very strange effects since A * B != B * A with matrices.

/Joachim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.