How can I use the Model Matrix to determine where and how was a vector rotated?
Posted on 2003-02-18
Here is my problem. I know the rotation (angleX, angleY) of a vector, and I can create a matrix that completes that rotation or I can use glRotatef() and let OpenGL make the matrix for me. Then I can retrieve that matrix with let say
After that I try to apply that matrix to a vector - and to retrieve the new vector coordinates and there comes the problem - IT IS NEVER ACCURATE. If I let opengl transform the vector everything works fine, but when I try to multiply my vector with the matrix - the new coordinates are off.
Here is the part of my code:
void Rotate(GLfloat angle, GLfloat x, GLfloat y, CVector3D &vView)
v1 = vView.X();
v1 = vView.Y();
v1 = vView.Z();
v1 = 1;
int index, alpha;
for (index = 0; index < 4; index++)
for (alpha = 0; alpha < 4; alpha++)
sum += n[index + alpha*4] * v1[alpha];
v2[index] = (float)sum;
vView = CVector3D(v2, v2, v2);
This function is supposed to rotate the velocity vector for the particle from a rotation angle.