matrix rotate and transform vectors.

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

Recommended Posts

I need help regarding the following piece of code:
CMatrix mat;
mat.Rotate( Angle / (float)M_PI * 180.0f );
mat.TransformVectors( vectors, 1 );

I'd like to understand what TransformVectors actually does, is there any code example I can take a look at?, perhaps a matrix library?. I wrote my own implementation out of the blue and it's giving incorrect results, that's why I'm puzzled about this. Thanks

Share on other sites
It looks like they're storing a rotation in the matrix and then transforming the vector by that matrix (by multiplying the vector by the matrix).

This is code in a project of mine which does essentially the same thing. Think of it as the vector being transformed by the matrix (instead of the other way around).

// Gets the matrix transformation.gfx::m4r<GLfloat> trans;glGetFloatv(GL_MODELVIEW_MATRIX, *trans);gfx::v4r<GLfloat> vertex_normal(	normal_array,	normal_array[i+1],	normal_array[i+2],	0);vertex_normal.rotate(trans); // Rotates the vector using the matrix.// Essentially vertex_normal = vertex_normal * rotation_part_of_transform_matrix

Share on other sites
I wonder if this is an efficient way of going around this. I've seen it on routines that transform vectors from world to relative and vice versa but I don't think it's anywhere efficient

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633768
• Total Posts
3013736
×