Direction Cosine - Definition, Formula, and Examples

#Geometry
TL;DR
The direction cosines of a vector are the cosines of the three angles α,β,γ\alpha, \beta, \gamma it makes with the positive xx, yy, and zz axes, written l=cos⁡αl = \cos\alpha, m=cos⁡βm = \cos\beta, n=cos⁡γn = \cos\gamma. For a vector a,i^+b,j^+c,k^a,\hat{i} + b,\hat{j} + c,\hat{k} they are each component over the magnitude, and they always satisfy l2+m2+n2=1l^2 + m^2 + n^2 = 1. This guide derives the formulas, proves that identity, and works six examples.
MV
Madhukar VLast updated on July 27, 202610 min read

What Is a Direction Cosine?

A direction cosine of a vector is the cosine of the angle that the vector makes with one of the positive coordinate axes. A vector in 3D makes three such angles - α\alpha with the xx-axis, β\beta with the yy-axis, γ\gamma with the zz-axis - so it has three direction cosines, written

l=cos⁡α,m=cos⁡β,n=cos⁡γl = \cos\alpha, \qquad m = \cos\beta, \qquad n = \cos\gamma

These three numbers capture the vector's direction completely, independent of its length. Two vectors pointing the same way have identical direction cosines even if one is ten times longer. Here α\alpha, β\beta, and γ\gamma are the ∠ measured from each positive axis to the vector, always taken between 0°0° and 180°180°.

The Three Numbers That Pin Down a Spacecraft's Tilt

Every spacecraft in orbit tracks its own tilt using three cosines and nothing more. Instead of storing a full picture of which way it points, a guidance computer keeps the cosines of the angles its axis makes with three fixed directions - and from those three numbers alone it reconstructs the orientation exactly. Those numbers are direction cosines, and the same idea that steers a satellite is what a student meets when a vector is resolved along the coordinate axes.

How Do You Calculate Direction Cosines of a Vector?

For a vector r⃗=a,i^+b,j^+c,k^\vec{r} = a,\hat{i} + b,\hat{j} + c,\hat{k}, each direction cosine is a component divided by the vector's magnitude. The magnitude is

r=a2+b2+c2r = \sqrt{a^2 + b^2 + c^2}

and then

l=ar,m=br,n=crl = \frac{a}{r}, \qquad m = \frac{b}{r}, \qquad n = \frac{c}{r}

Each formula reads "how much of the vector points along this axis, as a fraction of its total length." Dividing by rr is what strips out the length and leaves pure direction - the same normalising step used to build a unit projection vector. The three variables mean: a,b,ca, b, c are the components, rr is the length, and l,m,nl, m, n are the resulting cosines.

What Are the Direction Cosines of the x, y, and z Axes?

The coordinate axes are the simplest vectors to resolve, and their direction cosines are worth memorising because they anchor every other case. Each axis makes a 0°0° angle with itself and 90°90° with the other two, and since cos⁡0°=1\cos 0° = 1 and cos⁡90°=0\cos 90° = 0:

Axis

Angles (α,β,γ)(\alpha, \beta, \gamma)

Direction cosines (l,m,n)(l, m, n)

xx-axis

(0°,90°,90°)(0°, 90°, 90°)

(1,0,0)(1, 0, 0)

yy-axis

(90°,0°,90°)(90°, 0°, 90°)

(0,1,0)(0, 1, 0)

zz-axis

(90°,90°,0°)(90°, 90°, 0°)

(0,0,1)(0, 0, 1)

Each row satisfies l2+m2+n2=1l^2 + m^2 + n^2 = 1 trivially, since only one cosine is non-zero. These triples are exactly the components of the unit vectors i^\hat{i}, j^\hat{j}, and k^\hat{k} - a reminder that the direction cosines of any vector are just the components of the unit vector pointing the same way.

Why Does l² + m² + n² = 1?

This is the defining property of direction cosines, and it drops straight out of the formulas above. Square each one and add:

l2+m2+n2=a2r2+b2r2+c2r2=a2+b2+c2r2l^2 + m^2 + n^2 = \frac{a^2}{r^2} + \frac{b^2}{r^2} + \frac{c^2}{r^2} = \frac{a^2 + b^2 + c^2}{r^2}

But r2=a2+b2+c2r^2 = a^2 + b^2 + c^2 by definition of the magnitude, so the numerator and denominator are the same:

l2+m2+n2=r2r2=1l^2 + m^2 + n^2 = \frac{r^2}{r^2} = 1

The identity is really the Pythagorean theorem in three dimensions wearing different clothes. It is also a fast self-check: if you compute three direction cosines and their squares do not sum to 1, one of them is wrong.

What Is the Difference Between Direction Cosines and Direction Ratios?

This is the distinction that trips most students, so it is worth stating cleanly. Direction cosines (l,m,nl, m, n) are the normalised numbers that satisfy l2+m2+n2=1l^2 + m^2 + n^2 = 1 - a vector has exactly one set of them. Direction ratios are any three numbers (a,b,c)(a, b, c) proportional to the direction cosines - a vector has infinitely many sets, since scaling all three by the same non-zero factor gives the same direction.

Direction ratios

Direction cosines

Notation

a,b,ca, b, c

l,m,nl, m, n

How many sets

Infinitely many

Exactly one

Constraint

None

l2+m2+n2=1l^2 + m^2 + n^2 = 1

Get from the other

a=kl, b=km, c=kna = kl,\ b = km,\ c = kn

l=aa2+b2+c2l = \dfrac{a}{\sqrt{a^2+b^2+c^2}}

So the components of a vector are one convenient set of direction ratios, and dividing them by the magnitude turns them into the unique direction cosines.

Examples of Direction Cosine

Six examples, from a plain component vector to recovering an unknown cosine from the identity.

Example 1

Find the direction cosines of the vector r⃗=2,i^+3,j^+6,k^\vec{r} = 2,\hat{i} + 3,\hat{j} + 6,\hat{k}.

First the magnitude:

r=22+32+62=4+9+36=49=7r = \sqrt{2^2 + 3^2 + 6^2} = \sqrt{4 + 9 + 36} = \sqrt{49} = 7

Then each cosine is a component over rr:

l=27,m=37,n=67l = \frac{2}{7}, \qquad m = \frac{3}{7}, \qquad n = \frac{6}{7}

Final answer: (27,37,67)\left(\frac{2}{7}, \frac{3}{7}, \frac{6}{7}\right). As a check, 449+949+3649=4949=1\frac{4}{49} + \frac{9}{49} + \frac{36}{49} = \frac{49}{49} = 1.

Example 2

A student finds the direction cosines of r⃗=4,i^+0,j^+3,k^\vec{r} = 4,\hat{i} + 0,\hat{j} + 3,\hat{k} by writing "l=4,m=0,n=3l = 4, m = 0, n = 3." Where does this go wrong?

The tempting move reads the components straight off as the direction cosines, giving (4,0,3)(4, 0, 3).

That skips the essential step. Components are direction ratios, not direction cosines; direction cosines must be divided by the magnitude so that their squares sum to 1. Here 42+02+32=25≠14^2 + 0^2 + 3^2 = 25 \neq 1, so (4,0,3)(4, 0, 3) cannot be direction cosines.

The correct method normalises first:

r=42+02+32=25=5r = \sqrt{4^2 + 0^2 + 3^2} = \sqrt{25} = 5

l=45,m=0,n=35l = \frac{4}{5}, \qquad m = 0, \qquad n = \frac{3}{5}

Final answer: (45,0,35)\left(\frac{4}{5}, 0, \frac{3}{5}\right). Direction cosines are always the normalised version, never the raw components.

Example 3

A line has direction ratios (2,−1,2)(2, -1, 2). Find its direction cosines.

Magnitude of the ratio vector:

r=22+(−1)2+22=4+1+4=9=3r = \sqrt{2^2 + (-1)^2 + 2^2} = \sqrt{4 + 1 + 4} = \sqrt{9} = 3

Divide each ratio by 3:

l=23,m=−13,n=23l = \frac{2}{3}, \qquad m = -\frac{1}{3}, \qquad n = \frac{2}{3}

Final answer: (23,−13,23)\left(\frac{2}{3}, -\frac{1}{3}, \frac{2}{3}\right). The negative sign is kept — it says the vector points the negative-yy way.

Example 4

A vector makes 60°60° with the xx-axis and 45°45° with the yy-axis. Find the cosine of the angle it makes with the zz-axis.

Use l2+m2+n2=1l^2 + m^2 + n^2 = 1 with l=cos⁡60°=12l = \cos 60° = \tfrac{1}{2} and m=cos⁡45°=12m = \cos 45° = \tfrac{1}{\sqrt{2}}.

(12)2+(12)2+n2=1\left(\tfrac{1}{2}\right)^2 + \left(\tfrac{1}{\sqrt{2}}\right)^2 + n^2 = 1

14+12+n2=1\frac{1}{4} + \frac{1}{2} + n^2 = 1

n2=1−34=14n^2 = 1 - \frac{3}{4} = \frac{1}{4}

n=±12n = \pm\frac{1}{2}

Final answer: n=cos⁡γ=±12n = \cos\gamma = \pm\tfrac{1}{2}, so γ=60°\gamma = 60° or 120°120°. The identity fixes the third cosine from the first two.

Example 5

Find the direction cosines of the vector joining A(1,2,3)A(1, 2, 3) to B(4,6,3)B(4, 6, 3).

The vector AB⃗\vec{AB} has components B−A=(4−1, 6−2, 3−3)=(3,4,0)B - A = (4-1,\ 6-2,\ 3-3) = (3, 4, 0).

r=32+42+02=25=5r = \sqrt{3^2 + 4^2 + 0^2} = \sqrt{25} = 5

l=35,m=45,n=0l = \frac{3}{5}, \qquad m = \frac{4}{5}, \qquad n = 0

Final answer: (35,45,0)\left(\frac{3}{5}, \frac{4}{5}, 0\right). The zero nn says AB⃗\vec{AB} lies flat in a plane of constant zz.

Example 6

Can (12,12,12)\left(\frac{1}{2}, \frac{1}{2}, \frac{1}{2}\right) be the direction cosines of a vector?

Test them against l2+m2+n2=1l^2 + m^2 + n^2 = 1.

(12)2+(12)2+(12)2=14+14+14=34\left(\tfrac{1}{2}\right)^2 + \left(\tfrac{1}{2}\right)^2 + \left(\tfrac{1}{2}\right)^2 = \frac{1}{4} + \frac{1}{4} + \frac{1}{4} = \frac{3}{4}

Final answer: no. Since the squares sum to 34\tfrac{3}{4}, not 1, these cannot be direction cosines. The correct equal-cosine set would be (13,13,13)\left(\frac{1}{\sqrt{3}}, \frac{1}{\sqrt{3}}, \frac{1}{\sqrt{3}}\right).

Why Direction Cosines Matter: Direction Without Length

Direction cosines exist to answer one question cleanly: which way is this pointing, ignoring how far? That separation of direction from magnitude is exactly what makes them useful far beyond the textbook.

  • They give a unit description of direction. The triple (l,m,n)(l, m, n) is the components of the unit vector along r⃗\vec{r}, so it names the direction on a common scale every vector shares.

  • They feed the angle between vectors. The cosine of the angle between two vectors is built from their direction cosines, which is why resolving both onto the axes comes first.

  • They encode orientation in 3D. Stacked into a table, direction cosines form the rotation description that carries a body's tilt from one frame to another.

What Are the Most Common Mistakes With Direction Cosines?

Three errors cause most wrong answers, and each traces back to skipping the normalising step or the sign.

Mistake 1: Using components as direction cosines directly

Where it slips in: Reading a,i^+b,j^+c,k^a,\hat{i} + b,\hat{j} + c,\hat{k} and reporting (a,b,c)(a, b, c) as the cosines.

Don't do this: Writing the direction cosines of 2i^+3j^+6k^2\hat{i} + 3\hat{j} + 6\hat{k} as (2,3,6)(2, 3, 6).

The correct way: Components are direction ratios; divide each by the magnitude r=a2+b2+c2r = \sqrt{a^2+b^2+c^2} to get direction cosines. Students first meeting the topic almost always skip the division, because the components look like they already describe direction. The check l2+m2+n2=1l^2 + m^2 + n^2 = 1 catches it instantly.

Mistake 2: Confusing direction ratios with direction cosines

Where it slips in: Being asked for direction cosines and giving a valid but un-normalised ratio set, or the reverse.

Don't do this: Reporting (2,−1,2)(2, -1, 2) as direction cosines when they are direction ratios.

The correct way: Direction ratios are any proportional triple and there are infinitely many; direction cosines are the single normalised triple that squares to 1. The memoriser who stores "components = direction" without the constraint lands here. Ask which the question wants, then normalise if it wants cosines.

Mistake 3: Dropping the sign of a component

Where it slips in: Squaring inside the magnitude and then forgetting the original sign of a negative component.

Don't do this: Writing m=+13m = +\tfrac{1}{3} for a vector with a −1-1 in the yy-slot.

The correct way: The magnitude rr is always positive, but each cosine keeps the sign of its component. A negative direction cosine is real and means the vector points the negative way along that axis. The second-guesser who "tidies" a minus sign away changes the direction entirely.

Conclusion

  • Direction cosines l=cos⁡αl = \cos\alpha, m=cos⁡βm = \cos\beta, n=cos⁡γn = \cos\gamma are the cosines of the angles a vector makes with the xx, yy, zz axes.

  • For ai^+bj^+ck^a\hat{i} + b\hat{j} + c\hat{k}, each is a component over the magnitude r=a2+b2+c2r = \sqrt{a^2+b^2+c^2}.

  • They always satisfy l2+m2+n2=1l^2 + m^2 + n^2 = 1 — a built-in self-check.

  • Direction ratios are any proportional triple; direction cosines are the unique normalised one.

To take vectors and 3D geometry further with a teacher, explore Bhanzu's geometry tutor, a high school math tutor, or math tutoring.

Practice These to Solidify Your Understanding

Work through these, then check your answers:

  1. Find the direction cosines of r⃗=1i^+2j^+2k^\vec{r} = 1\hat{i} + 2\hat{j} + 2\hat{k}. (Answer to Question 1: (13,23,23)\left(\tfrac{1}{3}, \tfrac{2}{3}, \tfrac{2}{3}\right), since r=3r = 3.)

  2. A line has direction ratios (6,3,−2)(6, 3, -2). Find its direction cosines. (Answer to Question 2: (67,37,−27)\left(\tfrac{6}{7}, \tfrac{3}{7}, -\tfrac{2}{7}\right), since r=7r = 7.)

  3. A vector makes 90°90° with the xx-axis and 60°60° with the yy-axis. Find cos⁡γ\cos\gamma. (Answer to Question 3: cos⁡γ=±12\cos\gamma = \pm\tfrac{1}{2}.)

If Question 2 tripped you, revisit Example 3 and keep the negative sign. Want a trainer to walk 3D vectors through with your child? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What are the direction cosines of a vector?
They are the cosines of the three angles the vector makes with the positive xx, yy, and zz axes: l=cos⁡αl = \cos\alpha, m=cos⁡βm = \cos\beta, n=cos⁡γn = \cos\gamma. For ai^+bj^+ck^a\hat{i} + b\hat{j} + c\hat{k}, each equals a component divided by the magnitude.
Why do direction cosines satisfy l² + m² + n² = 1?
Because each is a component over the magnitude, so their squares sum to a2+b2+c2r2\frac{a^2+b^2+c^2}{r^2}, and r2=a2+b2+c2r^2 = a^2+b^2+c^2. The ratio is 1 - a 3D form of the Pythagorean theorem.
What is the difference between direction ratios and direction cosines?
Direction ratios are any three numbers proportional to the direction; there are infinitely many. Direction cosines are the unique normalised set that squares to 1. Divide ratios by their magnitude to get cosines.
Can a direction cosine be negative?
Yes. It keeps the sign of its component, so a vector pointing the negative-xx way has a negative ll. Only the magnitude is always positive.
How many direction cosines does a vector have?
Three in 3D - one for each axis. In 2D a vector has two.
✍️ Written By
Madhukar V
Madhukar V
Math Columnist & Analyst
I see mathematics as more than just numbers and formulas—it is a way of thinking, questioning, and understanding the world around us. I work at the intersection of mathematics, EdTech, technology, and AI-powered learning, I enjoy exploring how mathematical ideas can be made simple, meaningful, and relatable. Through my articles, I aim to present mathematics with curiosity and a practical perspective, helping readers see the beauty and relevance behind every concept in a Bhanzu way.
LinkedIn
Related Articles
Book a FREE Demo ClassBook Now →