Preserving Normals

  • View

  • Download

Embed Size (px)


Preserving Normals. Lecture 28 Wed, Nov 12, 2003. The Effect of a Transformation on a Normal. What happens to a normal vector under a linear transformation? A translation? A rotation? A scaling? Other?. v. n. v. n. Rotations and Translations. - PowerPoint PPT Presentation


  • Preserving NormalsLecture 28Wed, Nov 12, 2003

  • The Effect of a Transformation on a NormalWhat happens to a normal vector under a linear transformation?A translation?A rotation?A scaling?Other?

  • Rotations and TranslationsIt seems intuitive that if u and v are orthogonal, then their images will be orthogonal under both translations and rotations, since these are rigid motions.

  • Rotations, Translations, and ScalingsHowever, under scalings, their images will, in general, not be orthogonal.

  • Rotations, Translations, and ScalingsNor will they be orthogonal under a shear transformation.

  • The Effect on a NormalLet v be a vector lying in the tangent plane.Let n be a unit normal vector at that

  • The Effect on a NormalThen n v = 0.Equivalently, if we regard n and v as 3 1 matrices, thennTv = 0,where nT is the transpose of n and the operation is matrix multiplication.

  • The Effect on a NormalLet M be a linear transformation.Then M maps v to v = Mv and M maps n to n = Mn.In general, v and n will not be orthogonal.That is because(n)Tv = (Mn)T(Mv) = (nTMT)(Mv)= nT(MTM)v 0. (?)

  • Transforming a NormalSo if Mn is not orthogonal to v, then what vector will be orthogonal to v?Lets try n = (M-1)Tn.Then nTv is (n)Tv = ((M-1)Tn)T(Mv)= (nTM-1)(Mv)= nT(M-1M)v= nTv = 0.

  • Transforming a NormalThis demonstrates that if the surface points are transformed by matrix M, then the surface normals should be transformed by the matrix (M-1)T, the transpose of the inverse, in order to remain normal to the surface.

  • The Case of TranslationsThe case of translations is very simple since the matrix does not change the normal vector in the first place.=



  • The Case of TranslationsIn the case of translations, we know that Mn = n and Mv = v.It follows that Mn and Mv are orthogonal since(Mn)T(Mv) = nTv = 0.

  • The Case of RotationsIn the case of rotations, the transpose of the inverse of the matrix is the same matrix again! (I.e., M-1 = MT.)Such a matrix is said to be orthonormal.Therefore,(Mn)T(Mv) = (nTMT)Mv= nT(MTM)v = nT(I)v = nTv = 0.

  • ScalingsLet M be the matrix of the scaling Scale(sx, sy, sz).ThenM =(M-1)T =



  • ScalingsUnder the scaling Scale(sx, sy, sz), the point P = (x, y, z) is transformed into the pointP = MP = (sxx, syy, szz).But the normal vector n = (nx, ny, nz) must be transformed into the normal vectorn = (M-1)Tn = (nx/sx, ny/sy, nz/sz).

  • Other TransformationsFor other transformations, we must apply the transpose of the inverse matrix to the normal vectors to produce normals to the transformed surface.

  • Consequences for ProgrammingOpenGL applies transformation matrices to both the vertices but it applies the transpose of the inverse to the normals.One consequence is that, if we compute the transformed normals ourselves, then we must be sure to apply the transpose of the inverse and renormalize.

  • Consequences for ProgrammingHowever,In translations, it is not necessary to do anything.In rotations, we may apply the very same matrix.

  • Renormalizing Vectors in OpenGL Luckily, OpenGL will automatically recalculate normals if we ask it to.We should write the statementglEnable(GL_NORMALIZE);This statement forces OpenGL to renormalize all surface normals after transformations, throughout the program.

  • CautionThis function call is expensive since unit normals have already been computed and now they must be recomputed.It should be used only if the transformations include scalings or non-standard transformations.It would be more efficient to compute the correct normals from the start, if the situation allows for that.

  • Example: Scaling in the Mesh ClassNormScaler.cppmesh2.cppvector3.cpp