What is a Unit Vector?
A unit vector is a vector with magnitude equal to 1. Unit vectors represent direction only, without any scaling.
\[|\hat{v}| = 1\]
Standard Unit Vectors
The standard unit vectors point along the coordinate axes:
\(\hat{i}\)
(1, 0, 0)
x-axis
\(\hat{j}\)
(0, 1, 0)
y-axis
\(\hat{k}\)
(0, 0, 1)
z-axis
Any vector can be written as a combination of unit vectors:
\[\vec{v} = (3, 4, 2) = 3\hat{i} + 4\hat{j} + 2\hat{k}\]
Creating Unit Vectors (Normalization)
To convert any non-zero vector to a unit vector, divide by its magnitude:
\[\hat{v} = \frac{\vec{v}}{|\vec{v}|}\]
Example: Normalize (3, 4)
|v| = √(9 + 16) = 5
û = (3/5, 4/5) = (0.6, 0.8)
Verify: √(0.36 + 0.64) = √1 = 1 ✓
Applications
- Direction vectors: Represent direction without magnitude
- Surface normals: Unit vectors perpendicular to surfaces
- Basis vectors: Define coordinate systems
- Cosine similarity: Normalized vectors for AI/ML
Code Examples
// JavaScript
function normalize(v) {
const mag = Math.sqrt(v.reduce((s, x) => s + x*x, 0));
return v.map(x => x / mag);
}
normalize([3, 4]); // [0.6, 0.8]
💡
Unit Vectors Explained Simply
Think of a unit vector as a "direction-only" pointer with a fixed length of exactly 1. It tells you which way to go, but nothing about how far.
The Compass Analogy
Imagine a compass needle. It always points north, but the needle itself doesn't tell you the distance to the North Pole. A unit vector works the same way—it's pure direction without any sense of distance or magnitude. Whether you're traveling 10 miles or 10,000 miles north, the compass needle (unit vector) stays the same.
What is Normalization?
Normalization is like resizing a photograph to fit a standard frame. You keep the same image (direction), but scale it to a specific size (length = 1). To normalize any vector, simply divide it by its own length. The result? A unit vector pointing in the exact same direction.
Why Length 1?
Having a length of exactly 1 makes math simple. Want a vector 5 units long pointing northeast? Take the northeast unit vector and multiply by 5. It's like having a recipe measured for one serving—scale up or down as needed.
Real-World Example
In video games, when a character moves diagonally, the game uses unit vectors to ensure consistent speed in all directions. Without normalization, moving diagonally would be faster than moving straight—unit vectors fix this by separating "which way" from "how fast."