YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Normalizing a Vector - Interactive 3D Graphics

Get Embed Code
2 Languages

Showing Revision 2 created 05/25/2016 by Udacity Robot.

  1. To shade a diffuse surface, we need the cosine of the angle between the
  2. direction to the light and the surface's normal. We can perform a vector
  3. operation called the dot product to directly compute this cosine. First, you
  4. must normalize the surface normal and the vector to the light. Normalizing means
  5. rescaling a vector so that it has a length of 1. Normalized vectors are the norm
  6. in reflection models. As we'll see, if a dot product of two normalized vectors
  7. gives a value between negative 1 and 1, which will prove useful in computing the
  8. effect of lighting. For example, say, I have the vector 3, negative 4, 0. To
  9. normalize it, I find the length of the vector. This is simply the Pythagorean
  10. theorem. Take each component of the vector and square it. 3 squared is 9,
  11. negative 4 squared is 16, and 0 squared is 0. Take the square root of 25 and you
  12. get the length of the vector, 5. It's lucky that turned out so easily. By
  13. dividing the vector by its length, you get to normalize vector. So, 3, negative
  14. 4, 0 normalized is 0.6, negative 0.8, 0. Looking at this vector, it goes the
  15. same direction, but only travels one unit. Note that normalizing a vector that's
  16. already normalized leaves it unchanged. Try normalizing this vector again and
  17. you'll find the length is 1. Dividing the vector by a length of 1, of course,
  18. does nothing. It's very handy to normalize vectors in this way. Usually, we
  19. store the surface normals as normalized vectors. We'll see exactly why in the
  20. next lesson. For now, a quick quiz.