Search code examples
c#3dxna

Question regarding Vector3.normalize();


After reading google, I still don't quite understand what this does/means? Could someone explain this? Possibly a simple example? Thank you very much.


Solution

  • Normalizing a vector means changing its components so its total length is equal to 1.

    In pseudo-code:

    length = sqrt((vec.x * vec.x) + (vec.y * vec.y) + (vec.z * vec.z))
    vec.x /= length
    vec.y /= length
    vec.z /= length
    

    This has many uses in real-time 3D, as normed vectors have interesting properties.