Every line in space points in a definite direction, and the cleanest way to record that direction with numbers is through its direction cosines. If a directed line makes angles $\alpha,\beta,\gamma$ with the positive $x$, $y$ and $z$ axes, then its direction cosines are
$$l=\cos\alpha,\qquad m=\cos\beta,\qquad n=\cos\gamma.$$
These three numbers travel together as an ordered triple $(l,m,n)$. Reversing the direction of the line replaces every angle by its supplement, so the direction cosines become $(-l,-m,-n)$. An undirected line therefore has two sets of direction cosines, equal and opposite; we usually quote either one.
The fundamental identity
The single most important fact in this whole topic is that direction cosines are never independent — they always satisfy
$$l^2+m^2+n^2=1.$$
This follows from dropping a perpendicular: if a point on the line at distance $r$ from the origin has coordinates $(x,y,z)$, then $x=lr,\ y=mr,\ z=nr$, and $x^2+y^2+z^2=r^2$ forces $l^2+m^2+n^2=1$. The identity is both a check (any claimed triple of cosines must satisfy it) and a tool (given two cosines, the third is fixed up to sign).
Direction ratios
In practice we rarely know the cosines directly; we know three numbers proportional to them. Any three numbers $a,b,c$ (not all zero) that are proportional to $l,m,n$ are called direction ratios (DRs) of the line. Unlike cosines, direction ratios are not unique: if $(a,b,c)$ is a set of DRs, so is $(ka,kb,kc)$ for any non-zero $k$. They carry the direction but not the scale.
From ratios to cosines
To turn direction ratios into direction cosines, divide each by the magnitude $\sqrt{a^2+b^2+c^2}$:
$$l=\dfrac{a}{\sqrt{a^2+b^2+c^2}},\quad m=\dfrac{b}{\sqrt{a^2+b^2+c^2}},\quad n=\dfrac{c}{\sqrt{a^2+b^2+c^2}}.$$
The $\pm$ sign on the square root reflects the two possible directions of the line. Conversely, the direction cosines are themselves a valid (and the unique normalised) set of direction ratios, because $l:m:n=a:b:c$.
Direction ratios from two points
The most common way a line is handed to you is via two points on it. The line through $A(x_1,y_1,z_1)$ and $B(x_2,y_2,z_2)$ has direction ratios equal to the coordinate differences:
$$\big(x_2-x_1,\ y_2-y_1,\ z_2-z_1\big).$$
Its direction cosines follow by dividing these by $AB=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}$.
Direction cosines of the axes
| Axis | Angles with $x,y,z$ | Direction cosines |
|---|
| $x$-axis | $0^\circ,90^\circ,90^\circ$ | $(1,0,0)$ |
| $y$-axis | $90^\circ,0^\circ,90^\circ$ | $(0,1,0)$ |
| $z$-axis | $90^\circ,90^\circ,0^\circ$ | $(0,0,1)$ |
Collinearity via direction ratios. Three points $A,B,C$ are collinear precisely when $\vec{AB}$ and $\vec{AC}$ have proportional direction ratios — that is, the two lines they determine point the same way. This is far quicker than the distance test and is the standard exam method.
Deeper Insight — why direction cosines are the "address" of a direction. Direction ratios tell you which way a line points but leave the scale free; direction cosines pin down the same information in a canonical, scale-free form because the identity $l^2+m^2+n^2=1$ removes the one remaining degree of freedom. That is exactly why every later formula in this chapter — angle between lines, the projection of a segment, the shortest distance — can be written in terms of cosines or, equivalently, of any direction ratios. Get comfortable sliding between the two: think in ratios while computing (no square roots), then normalise to cosines only when an angle or a unit vector is actually required.
Find the direction cosines of a line with direction ratios $1,2,2$.
Solution- Magnitude $=\sqrt{1^2+2^2+2^2}=\sqrt{9}=3$.
- Divide each ratio by $3$: $l=\tfrac13,\ m=\tfrac23,\ n=\tfrac23$.
- Check: $l^2+m^2+n^2=\dfrac{1+4+4}{9}=1.$ ✓
Answer: $\left(\tfrac13,\tfrac23,\tfrac23\right)$.
Find direction ratios of the line joining $A(1,2,3)$ and $B(4,5,6)$.
Solution- Subtract coordinates: $(4-1,\ 5-2,\ 6-3)=(3,3,3)$.
- Direction ratios may be scaled, so divide by $3$.
Answer: DRs are $(3,3,3)$, or simplified $(1,1,1)$.
A line makes equal angles with the three axes. Find its direction cosines.
Solution- Equal angles means $l=m=n$.
- Substitute in the identity: $l^2+l^2+l^2=1\Rightarrow 3l^2=1$.
- So $l=\pm\dfrac{1}{\sqrt3}$.
Answer: $\left(\pm\tfrac{1}{\sqrt3},\pm\tfrac{1}{\sqrt3},\pm\tfrac{1}{\sqrt3}\right)$; the angle is $\cos^{-1}\!\left(\tfrac{1}{\sqrt3}\right)\approx 54.7^\circ$.
Can $\tfrac12,\tfrac12,\tfrac12$ be the direction cosines of a line?
Solution- Test the fundamental identity: $\left(\tfrac12\right)^2+\left(\tfrac12\right)^2+\left(\tfrac12\right)^2=\tfrac34$.
- Since $\tfrac34\ne 1$, the identity fails.
Answer: No — direction cosines must satisfy $l^2+m^2+n^2=1$.
A line makes angles $90^\circ,60^\circ,30^\circ$ with the $x,y,z$ axes. Find its direction cosines and verify them.
Solution- $l=\cos 90^\circ=0$.
- $m=\cos 60^\circ=\tfrac12$.
- $n=\cos 30^\circ=\tfrac{\sqrt3}{2}$.
- Check: $0+\tfrac14+\tfrac34=1.$ ✓
Answer: $\left(0,\ \tfrac12,\ \tfrac{\sqrt3}{2}\right)$.
Find the direction cosines of the line joining $P(-2,4,-5)$ and $Q(1,2,3)$.
Solution- DRs $=(1-(-2),\ 2-4,\ 3-(-5))=(3,-2,8)$.
- Magnitude $=\sqrt{3^2+(-2)^2+8^2}=\sqrt{9+4+64}=\sqrt{77}$.
- Divide each ratio by $\sqrt{77}$.
Answer: $\left(\dfrac{3}{\sqrt{77}},\ \dfrac{-2}{\sqrt{77}},\ \dfrac{8}{\sqrt{77}}\right)$.
If a line has direction ratios $2,-1,-2$, find its direction cosines.
Solution- Magnitude $=\sqrt{2^2+(-1)^2+(-2)^2}=\sqrt{4+1+4}=3$.
- Divide each by $3$.
Answer: $\left(\tfrac23,\ -\tfrac13,\ -\tfrac23\right)$.
Show that the points $A(2,3,-4),\ B(1,-2,3),\ C(3,8,-11)$ are collinear.
Solution- DRs of $AB=(1-2,\ -2-3,\ 3-(-4))=(-1,-5,7)$.
- DRs of $AC=(3-2,\ 8-3,\ -11-(-4))=(1,5,-7)$.
- Compare: $(1,5,-7)=-1\times(-1,-5,7)$, so the ratios are proportional.
- Both segments share point $A$ and point the same way.
Answer: The points are collinear, since $\vec{AB}$ and $\vec{AC}$ have proportional direction ratios.
A line makes angles $90^\circ,135^\circ,45^\circ$ with the $x,y,z$ axes. Find its direction cosines.
Solution- $l=\cos 90^\circ=0$.
- $m=\cos 135^\circ=-\tfrac{1}{\sqrt2}$.
- $n=\cos 45^\circ=\tfrac{1}{\sqrt2}$.
- Check: $0+\tfrac12+\tfrac12=1.$ ✓
Answer: $\left(0,\ -\tfrac{1}{\sqrt2},\ \tfrac{1}{\sqrt2}\right)$.
Two of the direction cosines of a line are $l=\tfrac{1}{\sqrt2}$ and $m=\tfrac12$. Find the third.
Solution- Use $l^2+m^2+n^2=1$: $\tfrac12+\tfrac14+n^2=1$.
- So $n^2=1-\tfrac34=\tfrac14$.
- Hence $n=\pm\tfrac12$ (the line has two possible directions).
Answer: $n=\pm\tfrac12$.
Find the direction cosines of the line $\vec r$ joining $A(1,0,0)$ and $B(0,1,1)$.
Solution- DRs $=(0-1,\ 1-0,\ 1-0)=(-1,1,1)$.
- Magnitude $=\sqrt{(-1)^2+1^2+1^2}=\sqrt3$.
- Divide each by $\sqrt3$.
Answer: $\left(-\tfrac{1}{\sqrt3},\ \tfrac{1}{\sqrt3},\ \tfrac{1}{\sqrt3}\right)$.