Jump to content
  • Advertisement
Sign in to follow this  

matrix rotate and transform vectors.

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

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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(
vertex_normal.rotate(trans); // Rotates the vector using the matrix.
// Essentially vertex_normal = vertex_normal * rotation_part_of_transform_matrix

Share this post

Link to post
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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!