Original Post
Hi, everybody!
I don''t speak (and write) English well. I''m sorry!!!!
But I''m trying to make a simple billiard game and
this site is where I found the most interesting articles on physic simulation and
game programming. So I do try to write in right way...
I''ve a "little" problem...
Everything seems to go well... but ball rotation doesn''t look ok.
...the ball begins to roll well, but after little time it begins to roll
around a wrong axis until it allineates with the same direction every time and
rotates so long around the same axis.
So, whatever is the initial orientation, finally it rotates around the same "wrong" axis.
Because of the final wrong axis is always the X axis I think the problem is in the following code.
Look at this code:
Matrix& Matrix::
Normalize ()
{
Vector X(Mat[0][0], Mat[1][0], Mat[2][0]);
Vector Y(Mat[0][1], Mat[1][1], Mat[2][1]);
Vector Z;
X.Normalize();
Z = (X ^ Y);
Z.Normalize();
Y = (Z ^ X);
Y.Normalize();
Mat[0][0] = X(0); Mat[0][1] = Y(0); Mat[0][2] = Z(0);
Mat[1][0] = X(1); Mat[1][1] = Y(1); Mat[1][2] = Z(1);
Mat[2][0] = X(2); Mat[2][1] = Y(2); Mat[2][2] = Z(2);
return (*this);
}
I use this method to normalize a matrix the coloumns of which represent the axes of orientation of the ball in the 3d-space.
I use X axis to (re)normalize the other two.
Maybe it''s a round-off error problem?!
Anyway, could you suggest me links to interesting resources about this matter?
Thanks, very much!!