Normalizing a Nonzero Vector
Dividing a vector by its positive norm gives unit length under that norm while keeping its direction.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a two-component vector
Vector \((3,4)\) has Euclidean length five and normalizes to \((3/5,4/5)\). Its squared length becomes \(9/25+16/25=1\). Euclidean distance and max norm show why the selected norm matters.
Check the zero case
The zero vector cannot be normalized by division by its norm. Decide whether to report a missing direction or reject that input under the function contract.[1][2]
Verify the result by taking its norm again
The vector \((6,8)\) has length ten, so normalization yields \((0.6,0.8)\). Its squared length is \(0.36+0.64=1\). Positive rescaling of the original does not change its unit direction in exact arithmetic. See avoiding intermediate overflow.
Norm of (6,8) = 10
Unit vector = (.6,.8)
Norm of (3,4) = 5
Same unit vector for this positive scaling
Choose a policy for zero and very small magnitude
Division by the zero norm is undefined. Very small rounded components can force a policy about unreliable input direction. Check direction and compare the norm with one using a documented tolerance.