Deriving the Direction Cosines of a Unit Vector
Direction Cosines of a Unit Vector
A vector in 3D can be written as
v = (x, y, z).
This vector points from the origin to the point (x, y, z). Its direction depends on how much it travels in the x-direction, the y-direction and the z-direction.
Magnitude of the Vector
The magnitude, or length, of v is
|v| = √(x² + y² + z²).
This comes from the 3D version of Pythagoras' theorem. The vector has three perpendicular components: x, y and z. Squaring them, adding them, and taking the square root gives the total length.
Unit Vector
A unit vector is a vector with length 1.
To turn v into a unit vector, divide every component by the magnitude of v:
v̂ = (1 / |v|)(x, y, z).
So
v̂ = (x / |v|, y / |v|, z / |v|).
This new vector points in the same direction as v, but its length is exactly 1.
The Dot Product
The dot product has two important forms.
Algebraic form:
a · b = a₁b₁ + a₂b₂ + a₃b₃.
Geometric form:
a · b = |a||b|cos(θ).
The algebraic form uses components. The geometric form uses the angle between the vectors. By comparing both forms, coordinates can be connected to angles.
The x-Axis Direction
The unit vector along the positive x-axis is
i = (1, 0, 0).
Now take the dot product of i with v:
i · v = (1, 0, 0) · (x, y, z).
Using the algebraic definition:
i · v = 1x + 0y + 0z.
So
i · v = x.
Using the geometric definition:
i · v = |i||v|cos(θ),
where θ is the angle between v and the positive x-axis.
Since i is a unit vector, |i| = 1. Therefore,
i · v = |v|cos(θ).
But we already found that i · v = x. Therefore,
x = |v|cos(θ).
Dividing both sides by |v| gives
x / |v| = cos(θ).
The y-Axis Direction
The unit vector along the positive y-axis is
j = (0, 1, 0).
Take the dot product of j with v:
j · v = (0, 1, 0) · (x, y, z).
Using the algebraic definition:
j · v = 0x + 1y + 0z.
So
j · v = y.
Using the geometric definition:
j · v = |j||v|cos(φ),
where φ is the angle between v and the positive y-axis.
Since |j| = 1,
j · v = |v|cos(φ).
Therefore,
y = |v|cos(φ).
Dividing both sides by |v| gives
y / |v| = cos(φ).
The z-Axis Direction
The unit vector along the positive z-axis is
k = (0, 0, 1).
Take the dot product of k with v:
k · v = (0, 0, 1) · (x, y, z).
Using the algebraic definition:
k · v = 0x + 0y + 1z.
So
k · v = z.
Using the geometric definition:
k · v = |k||v|cos(ψ),
where ψ is the angle between v and the positive z-axis.
Since |k| = 1,
k · v = |v|cos(ψ).
Therefore,
z = |v|cos(ψ).
Dividing both sides by |v| gives
z / |v| = cos(ψ).
Putting the Results Together
The unit vector is
v̂ = (x / |v|, y / |v|, z / |v|).
From the previous results,
x / |v| = cos(θ),
y / |v| = cos(φ),
z / |v| = cos(ψ).
Therefore,
v̂ = (cos(θ), cos(φ), cos(ψ)).
Meaning of the Result
This means that the components of a unit vector are not random. They are the cosines of the angles that the vector makes with the positive coordinate axes.
The first component tells how strongly the vector points in the x-direction.
The second component tells how strongly the vector points in the y-direction.
The third component tells how strongly the vector points in the z-direction.
These three values are called the direction cosines of the vector.
Direction Cosines
The direction cosines of v are
cos(θ), cos(φ), cos(ψ).
They describe the direction of the vector by measuring its angular relationship with the x-, y- and z-axes.
If the vector points strongly in the x-direction, then cos(θ) is large.
If the vector is perpendicular to the x-axis, then cos(θ) = 0.
If the vector points in the opposite direction to the positive x-axis, then cos(θ) is negative.
Important Identity
Since v̂ is a unit vector, its magnitude is 1.
Therefore,
|v̂| = 1.
Using
v̂ = (cos(θ), cos(φ), cos(ψ)),
we get
√(cos²(θ) + cos²(φ) + cos²(ψ)) = 1.
Squaring both sides gives
cos²(θ) + cos²(φ) + cos²(ψ) = 1.
This identity shows that the direction cosines behave like the components of a unit vector.
Why This Matters
This result is important because it links coordinates, angles and unit vectors. It shows that a direction in 3D can be described either by components or by angles with the coordinate axes.
In rotation matrices, the entries often come from cosines of angles between axes. This is why direction cosines appear naturally in 3D rotations, camera transformations, surface normals and computer graphics.
The central idea is simple:
A unit vector stores direction only, and its components are the direction cosines.