How do you convert a normal vector?

How do you convert a normal vector?

To correctly transform a normal vector n by a (non-singular) matrix M, multiply n by the INVERSE TRANSPOSE of matrix M.

What is being transformed by a transformation matrix?

A transformation matrix allows to alter the default coordinate system and map the original coordinates (x, y) to this new coordinate system: (x’, y’). Depending on how we alter the coordinate system we effectively rotate, scale, move (translate) or shear the object this way.

How do you translate a vector by a matrix?

If you treat your (generally 3d) vector (x, y, z) as a four vector (x, y, z, 1) you can do this: w = Av T , where T is the transpose operation (twist a horzontal vector vertical or vice versa) and A is a correctly chosen matrix, and w is the translated matrix. You do have to know how to do matrix multiplication.

What’s the problem with transforming normals into vectors?

The problem with normals, is that we tend to assume that transforming them in the same way we transform points and vectors will work.

Do you multiply normals by the transpose of the matrix?

Now, if we both draw our new transformed line (going through A’ and B’) and N’, we can see that N’ is no longer perpendicular to A’B’. In fact, the solution to transforming normals, is not to multiply them by the same matrix used for transforming points and vectors, but to multiply them by the transpose of the inverse of that matrix:

How is the change of basis used in the transformation matrix?

And to convert it to the basis space, we multiply the vector by the inverse of the basis matrix. Change of basis can be used to derive transformation matices. Counter-clockwise rotation by an angle θ is developed using unit vectors established by this angle:

Which is the normal vector transformation in OpenGL?

The following is the matrix rotating 30 degree along X-axis, and transforming a normal vector (0, 0, 1) multiplying by the inverse and transpose matrix should become (0, -0.5, 0.866). Note that the rotation-only matrix is unchanged after invert and transposed because it is an orthogonal matrix.