Direction Cosines: Definition Formula and Examples

#Direction Cosines
TL;DR
The direction cosines of a vector are the cosines of the angles α, β, γ it makes with the positive x, y and z axes: l = x/|v|, m = y/|v|, n = z/|v|. They always satisfy l² + m² + n² = 1.
Annie Charlette Sophia A·reviewed byMadhukar VLast updated on December 2, 202616 min read

Key Points

  • For v=xi^+yj^+zk^\mathbf{v} = x\hat{\mathbf{i}} + y\hat{\mathbf{j}} + z\hat{\mathbf{k}}: l=x∣v∣l = \dfrac{x}{|\mathbf{v}|}, m=y∣v∣m = \dfrac{y}{|\mathbf{v}|}, n=z∣v∣n = \dfrac{z}{|\mathbf{v}|}.
  • (l,m,n)(l, m, n) are the parts of the unit vector pointing the same way as v\mathbf{v}.
  • l2+m2+n2=1l^2 + m^2 + n^2 = 1 always: Pythagoras in 3D, and a quick check.
  • Direction ratios are any three numbers in the same proportion; direction cosines are the one set that squares to 1.

The Three Numbers That Pin Down a Spacecraft's Tilt

A spacecraft's guidance computer can record the craft's tilt in a small table of cosines. Each row holds the cosines of the angles one of the craft's axes makes with three fixed directions. Those numbers are direction cosines.

  • Take v=2i^+3j^+6k^\mathbf{v} = 2\hat{\mathbf{i}} + 3\hat{\mathbf{j}} + 6\hat{\mathbf{k}}. Its length is 4+9+36=7\sqrt{4 + 9 + 36} = 7.
  • Divide each part by 7: (27,37,67)\left(\tfrac{2}{7}, \tfrac{3}{7}, \tfrac{6}{7}\right). These are its direction cosines.
  • They say how steeply v\mathbf{v} leans towards each axis, and nothing about how long it is.
  • The angles are real ones you could measure with a protractor: about 73.4°73.4°, 64.6°64.6° and 31.0°31.0°. The smallest is with the z-axis, matching the biggest part, 6.
the direction cosines are the cosines of the angles a vector makes with the three axes
A 3D sketch with x, y and z axes and a dashed box 2 by 3 by 6. The purple vector v = 2i + 3j + 6k runs from the origin to the far corner, with shaded arcs marking α to the x-axis, β to the y-axis and γ to the z-axis. A panel lists l = 2/7 ≈ 0.286 with α ≈ 73.4°, m = 3/7 ≈ 0.429 with β ≈ 64.6°, n = 6/7 ≈ 0.857 with γ ≈ 31°, and l² + m² + n² = 1.

What Is a Direction Cosine?

A direction cosine is the cosine of the angle between a vector and one of the positive coordinate axes. A vector in 3D makes three such angles, its direction angles:

  • α with the positive x-axis, and l=cos⁡αl = \cos\alpha
  • β with the positive y-axis, and m=cos⁡βm = \cos\beta
  • γ with the positive z-axis, and n=cos⁡γn = \cos\gamma
  • Each angle is between 0°0° and 180°180°. Under 90°90° gives a positive cosine; over 90°90° a negative one.
  • Two vectors pointing the same way share direction cosines, whatever their lengths: they describe direction only.

How Do You Calculate Direction Cosines of a Vector?

Divide each component by the length of the vector. For v=xi^+yj^+zk^\mathbf{v} = x\hat{\mathbf{i}} + y\hat{\mathbf{j}} + z\hat{\mathbf{k}}:

∣v∣=x2+y2+z2,l=x∣v∣,m=y∣v∣,n=z∣v∣|\mathbf{v}| = \sqrt{x^2 + y^2 + z^2}, \qquad l = \frac{x}{|\mathbf{v}|}, \quad m = \frac{y}{|\mathbf{v}|}, \quad n = \frac{z}{|\mathbf{v}|}
  • xx, yy, zz are the components (the parts along each axis), and ∣v∣|\mathbf{v}| is the length.
  • Dividing by the length strips the size away, so (l,m,n)(l, m, n) is the unit vector (length 1) along v\mathbf{v}:
v^=v∣v∣=l i^+m j^+n k^\hat{\mathbf{v}} = \frac{\mathbf{v}}{|\mathbf{v}|} = l\,\hat{\mathbf{i}} + m\,\hat{\mathbf{j}} + n\,\hat{\mathbf{k}}

Why l = x / |v|: two ways to see it

With a right triangle:

  • Put the tail of v\mathbf{v} at the origin OO and call its tip PP. Drop a perpendicular from PP to the x-axis, landing at X=(x,0,0)X = (x, 0, 0).
  • The angle at XX is a right angle. Next to α is OX=xOX = x; the hypotenuse is OP=∣v∣OP = |\mathbf{v}|.
  • Adjacent over hypotenuse: cos⁡α=x÷∣v∣\cos\alpha = x \div |\mathbf{v}|. For our example, 2÷7≈0.2862 \div 7 \approx 0.286, so α≈73.4°\alpha \approx 73.4°.
the direction cosine l is adjacent over hypotenuse in a right triangle in space
A 3D sketch of the shaded right triangle O, X, P, with X = (2, 0, 0) on the x-axis, a right-angle mark at X, the purple vector OP and the angle α at O. A panel shows OX = 2, OP = 7, XP = √45 ≈ 6.71, and cos α = OX ÷ OP = 2/7 ≈ 0.286, so α ≈ 73.4°.

With the dot product:

  • The dot product gives v⋅i^=∣v∣cos⁡α\mathbf{v}\cdot\hat{\mathbf{i}} = |\mathbf{v}|\cos\alpha.
  • In components it is x×1+y×0+z×0=xx \times 1 + y \times 0 + z \times 0 = x. Set them equal: cos⁡α=x÷∣v∣\cos\alpha = x \div |\mathbf{v}|.
  • So each component is the vector's projection onto an axis.

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

Each axis makes 0°0° with itself and 90°90° with the other two, so its direction cosines are one 1 and two zeros.

Direction Angles (α,β,γ)(\alpha, \beta, \gamma) Direction cosines (l,m,n)(l, m, n)
positive x-axis (0°,90°,90°)(0°, 90°, 90°) (1,0,0)(1, 0, 0)
positive y-axis (90°,0°,90°)(90°, 0°, 90°) (0,1,0)(0, 1, 0)
positive z-axis (90°,90°,0°)(90°, 90°, 0°) (0,0,1)(0, 0, 1)
negative x-axis (180°,90°,90°)(180°, 90°, 90°) (−1,0,0)(-1, 0, 0)

The first three rows are the unit vectors i^\hat{\mathbf{i}}, j^\hat{\mathbf{j}} and k^\hat{\mathbf{k}}, and each row squares to 1 at a glance.

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

Because the direction cosines are the parts of a unit vector, and a unit vector has length 1. Square and add:

l2+m2+n2=x2+y2+z2∣v∣2=1l^2 + m^2 + n^2 = \frac{x^2 + y^2 + z^2}{|\mathbf{v}|^2} = 1
  • The last step uses ∣v∣2=x2+y2+z2|\mathbf{v}|^2 = x^2 + y^2 + z^2, which is Pythagoras used twice.
  • In a 2 by 3 by 6 box, the floor diagonal is 13\sqrt{13}, and with the height 6 the long diagonal is 13+36=7\sqrt{13 + 36} = 7.
  • A fast self-check: if the squares do not add to 1, a cosine is wrong.
l squared plus m squared plus n squared equals 1 is Pythagoras used twice
A box 2 by 3 by 6 with the purple vector v as its long diagonal. A shaded right triangle stands on the orange floor diagonal √13 ≈ 3.61 with the green height 6, and |v| = 7. A panel shows 2² + 3² = 13, 13 + 6² = 49, then divides |v|² = x² + y² + z² by |v|² to get 1 = l² + m² + n², checked as 4/49 + 9/49 + 36/49 = 1.

On a flat page it is a fact you know: β=90°−α\beta = 90° - \alpha, so l2+m2=cos⁡2α+sin⁡2α=1l^2 + m^2 = \cos^2\alpha + \sin^2\alpha = 1. For w=(4,3)\mathbf{w} = (4, 3), 0.82+0.62=10.8^2 + 0.6^2 = 1.

in two dimensions the direction cosine identity is cos squared plus sin squared equals one
On a grid, w = (4, 3) in purple with its right triangle shaded, α ≈ 36.9° marked from the x-axis and β ≈ 53.1° from the y-axis. A panel shows l = 4/5 = 0.8, m = 3/5 = 0.6, α + β = 90° so cos β = sin α, and l² + m² = cos²α + sin²α = 1, checked as 0.64 + 0.36 = 1.

In the tool below:

  • Press the "(2, 4, 4): length 6" preset. The cosines read (0.333,0.667,0.667)(0.333, 0.667, 0.667), and 19+49+49=1\tfrac{1}{9} + \tfrac{4}{9} + \tfrac{4}{9} = 1.
  • Drag the orange head. The length and cosines change, but the identity holds.

Try It Yourself

Use the vector lab to see Direction Cosines at work: drag, change the numbers and watch what happens.

What Is the Difference Between Direction Cosines and Direction Ratios?

Direction ratios are any three numbers proportional to the direction cosines; direction cosines are the one set that also squares to 1. The components of a vector are one set of direction ratios, and so is any non-zero multiple.

Direction ratios Direction cosines
Notation a,b,ca, b, c l,m,nl, m, n
Example for one direction (2,−1,2)(2, -1, 2), (4,−2,4)(4, -2, 4), (1,−0.5,1)(1, -0.5, 1) (23,−13,23)\left(\tfrac{2}{3}, -\tfrac{1}{3}, \tfrac{2}{3}\right)
How many sets infinitely many one for a vector
Condition none l2+m2+n2=1l^2 + m^2 + n^2 = 1
From the other multiply (l,m,n)(l, m, n) by any non-zero kk divide (a,b,c)(a, b, c) by a2+b2+c2\sqrt{a^2 + b^2 + c^2}
many sets of direction ratios share one set of direction cosines
A 3D sketch with three arrows along one line: (4, −2, 4) in orange, (2, −1, 2) in blue and the short purple unit vector. A panel lists the direction ratios (2, −1, 2), (4, −2, 4), (1, −0.5, 1), the length √(4 + 1 + 4) = 3, the direction cosines (2/3, −1/3, 2/3) and the check 4/9 + 1/9 + 4/9 = 1.

A vector or a line?

  • A vector has one set of direction cosines.
  • A line has no arrow, so it has two: (l,m,n)(l, m, n) and (−l,−m,−n)(-l, -m, -n).
  • That is why direction ratios are enough for the vector form of a line. The page on the direction ratio works from the ratio side.

The payoff: the angle between two lines

Direction cosines are unit vectors, so the angle θ between two directions comes straight from the dot product:

cos⁡θ=l1l2+m1m2+n1n2\cos\theta = l_1l_2 + m_1m_2 + n_1n_2

Edge Cases: Not Every Three Angles Work

You cannot choose α, β and γ freely: the identity limits them.

  • Equal angles. If α=β=γ\alpha = \beta = \gamma, then 3cos⁡2α=13\cos^2\alpha = 1, so α≈54.7°\alpha \approx 54.7° (or 125.3°125.3°). Three 60°60° angles are impossible: 3×14=343 \times \tfrac{1}{4} = \tfrac{3}{4}.
  • Two small angles. No vector makes 30°30° with both the x- and y-axes: cos⁡230°+cos⁡230°=1.5\cos^2 30° + \cos^2 30° = 1.5, already over 1.
  • A flat vector. In the xy-plane, γ=90°\gamma = 90° and n=0n = 0, so l2+m2=1l^2 + m^2 = 1.
  • The zero vector. It has no direction, so no direction cosines: the formula would divide by 0.

Examples of Direction Cosines

Six examples, from a plain vector to recovering a missing cosine.

Example 1

Find the direction cosines of v = 2i + 3j + 6k.

  1. Length: ∣v∣=4+9+36=49=7|\mathbf{v}| = \sqrt{4 + 9 + 36} = \sqrt{49} = 7.
  2. Divide each component: l=27l = \tfrac{2}{7}, m=37m = \tfrac{3}{7}, n=67n = \tfrac{6}{7}.
  3. Check: 4+9+3649=1\tfrac{4 + 9 + 36}{49} = 1. ✓

The direction cosines are (27,37,67)\left(\tfrac{2}{7}, \tfrac{3}{7}, \tfrac{6}{7}\right).

Example 2

A student gives the direction cosines of v = 4i + 3k as (4, 0, 3). Find the error.

  1. Test with the identity: 42+02+32=254^2 + 0^2 + 3^2 = 25, not 1. Those are direction ratios.
  2. Length: 16+0+9=5\sqrt{16 + 0 + 9} = 5.
  3. Divide: (45,0,35)\left(\tfrac{4}{5}, 0, \tfrac{3}{5}\right). Check: 0.64+0+0.36=10.64 + 0 + 0.36 = 1. ✓

Direction cosines are the normalised version, never the raw components.

Example 3

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

  1. Length: 4+1+4=3\sqrt{4 + 1 + 4} = 3.
  2. Divide: (23,−13,23)\left(\tfrac{2}{3}, -\tfrac{1}{3}, \tfrac{2}{3}\right). The minus sign stays.

A line has no arrow, so (−23,13,−23)\left(-\tfrac{2}{3}, \tfrac{1}{3}, -\tfrac{2}{3}\right) is the same line read the other way.

Example 4

A vector makes 60° with the x-axis and 45° with the y-axis. Find the angle it makes with the z-axis.

  1. l=cos⁡60°=12l = \cos 60° = \tfrac{1}{2}, m=cos⁡45°=12m = \cos 45° = \tfrac{1}{\sqrt{2}}, so l2+m2=34l^2 + m^2 = \tfrac{3}{4}.
  2. n2=1−34=14n^2 = 1 - \tfrac{3}{4} = \tfrac{1}{4}, so n=±12n = \pm\tfrac{1}{2}.

Two answers: γ=60°\gamma = 60° (pointing up) or γ=120°\gamma = 120° (pointing down), mirror images in the xy-plane.

two direction angles leave two possible values for the third
A 3D sketch with a shaded xy-plane. A green vector with n = +½ points up at γ = 60°, and an orange vector with n = −½ points down at γ = 120°, each with a dashed drop line to the plane. A panel shows l = ½, m = 1/√2, l² + m² = ¾, n² = ¼ and n = ±½.

Example 5

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

  1. AB→=(4−1,  6−2,  3−3)=(3,4,0)\overrightarrow{AB} = (4 - 1,\; 6 - 2,\; 3 - 3) = (3, 4, 0), length 9+16=5\sqrt{9 + 16} = 5.
  2. Divide: (35,45,0)\left(\tfrac{3}{5}, \tfrac{4}{5}, 0\right).

The zero says AB→\overrightarrow{AB} is level: it makes 90°90° with the z-axis.

Example 6

Can (1/2, 1/2, 1/2) be the direction cosines of a vector?

  1. 14+14+14=34≠1\tfrac{1}{4} + \tfrac{1}{4} + \tfrac{1}{4} = \tfrac{3}{4} \ne 1, so no.
  2. They are valid direction ratios. Divide by their length, 32\tfrac{\sqrt{3}}{2}.

The direction cosines are (13,13,13)\left(\tfrac{1}{\sqrt{3}}, \tfrac{1}{\sqrt{3}}, \tfrac{1}{\sqrt{3}}\right), the equal-angle direction.

Why Direction Cosines Matter: Direction Without Length

Direction cosines answer one question cleanly: which way is this pointing, ignoring how far?

  • A common scale for direction. (l,m,n)(l, m, n) is the unit vector along v\mathbf{v}, so every direction is named on the same scale.
  • Splitting a force. A 140 N guy rope runs from a tent pole top at T(0,0,6)T(0, 0, 6) m to a peg at P(2,3,0)P(2, 3, 0) m. Its direction (2,3,−6)(2, 3, -6) has length 7.
  • So the pull is 140×(27,37,−67)=(40,60,−120)140 \times \left(\tfrac{2}{7}, \tfrac{3}{7}, -\tfrac{6}{7}\right) = (40, 60, -120) N. The pole is pressed down by 120 N.
  • Orientation. A direction cosine matrix is a 3 × 3 table whose rows are the direction cosines of a craft's own axes. Each row must square to 1, which keeps the computed tilt physically possible.
a rope's pull splits into x, y and z parts using its direction cosines
A tent pole from the ground to T(0, 0, 6) with a guy rope down to a peg at P(2, 3, 0) on a green ground plane, and an orange 140 N arrow along the rope. A panel shows the rope TP = (2, 3, −6) of length 7 m, direction cosines (2/7, 3/7, −6/7), and the parts 40 N, 60 N and −120 N.

What Are the Most Common Mistakes With Direction Cosines?

Most wrong answers come from skipping the divide step or losing a sign.

Mistake 1: Using the components as the direction cosines

Where it slips in: Reading 2i^+3j^+6k^2\hat{\mathbf{i}} + 3\hat{\mathbf{j}} + 6\hat{\mathbf{k}} and writing (2,3,6)(2, 3, 6).

Don't do this: Skip the division by the length.

The correct way: Divide every component by ∣v∣|\mathbf{v}|, then check the squares add to 1. (2,3,6)(2, 3, 6) squares to 49.

Mistake 2: Mixing up ratios and cosines

Where it slips in: A question gives direction ratios and asks for direction cosines, or the other way round.

Don't do this: Hand back the ratios (2,−1,2)(2, -1, 2) when the question wants cosines.

The correct way: Read which one is wanted. Cosines are the one scaled set with l2+m2+n2=1l^2 + m^2 + n^2 = 1.

Mistake 3: Dropping a minus sign

Where it slips in: Squaring inside the square root, then forgetting a component's sign.

Don't do this: Write m=+13m = +\tfrac{1}{3} for a vector whose y-part is −1-1.

The correct way: The length is positive, but each cosine keeps its component's sign. A negative cosine means an angle over 90°90°.

Mistake 4: Taking only one root

Where it slips in: Finding the third cosine from the other two, as in Example 4.

Don't do this: Write n=12n = \tfrac{1}{2} and stop.

The correct way: n2=14n^2 = \tfrac{1}{4} gives ±12\pm\tfrac{1}{2}. Both are answers unless the question says up or down.

Conclusion

  • Direction cosines l=cos⁡αl = \cos\alpha, m=cos⁡βm = \cos\beta, n=cos⁡γn = \cos\gamma describe direction without size.
  • Each is a component over the length, so together they form the unit vector.
  • They always satisfy l2+m2+n2=1l^2 + m^2 + n^2 = 1; in 2D this is cos⁡2α+sin⁡2α=1\cos^2\alpha + \sin^2\alpha = 1.
  • Direction ratios are any proportional triple; a line has two sets of cosines, ±(l,m,n)\pm(l, m, n).
  • Keep the signs and take both roots when solving for a missing cosine.

Practice These to Solidify Your Understanding

Practice these to solidify your understanding, and check each answer with the identity:

  1. Find the direction cosines of i^+2j^+2k^\hat{\mathbf{i}} + 2\hat{\mathbf{j}} + 2\hat{\mathbf{k}}.
  2. A line has direction ratios (6,3,−2)(6, 3, -2). Find its direction cosines.
  3. A vector makes 90°90° with the x-axis and 60°60° with the y-axis. Find cos⁡γ\cos\gamma.

Answer to Question 1: (13,23,23)\left(\tfrac{1}{3}, \tfrac{2}{3}, \tfrac{2}{3}\right), since the length is 3.

Answer to Question 2: ±(67,37,−27)\pm\left(\tfrac{6}{7}, \tfrac{3}{7}, -\tfrac{2}{7}\right), since the length is 7.

Answer to Question 3: l=0l = 0 and m=12m = \tfrac{1}{2}, so n2=1−0−14=34n^2 = 1 - 0 - \tfrac{1}{4} = \tfrac{3}{4} and cos⁡γ=±32\cos\gamma = \pm\tfrac{\sqrt{3}}{2}, giving γ=30°\gamma = 30° or 150°150°.

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

Want a live Bhanzu trainer to walk your child through 3D vectors? Book a free demo class, online globally, or in person at our McKinney, TX center.

Read More

Research Behind This Article

  1. OpenStax, Calculus Volume 3, Section 2.3: The Dot Product (direction angles and direction cosines, the identity cos²α + cos²β + cos²γ = 1). openstax.org
  2. OpenStax, Calculus Volume 3, Section 2.2: Vectors in Three Dimensions (components, length and unit vectors in 3D). openstax.org
  3. OpenStax, University Physics Volume 1, Section 2.2: Coordinate Systems and Components of a Vector (direction angles and resolving a vector along axes). openstax.org
  4. OpenStax, Calculus Volume 3, Section 2.5: Equations of Lines and Planes in Space (direction vectors of lines and the angle between them). openstax.org
  5. Euclid, Elements, Book I, Proposition 47 (the Pythagorean theorem, used twice for the length of a 3D vector), D. E. Joyce, Clark University. mathcs.clarku.edu

Quick Quiz: Check Yourself

Three levels, questions with figures, instant feedback with the reason.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

How do you find the direction cosines of a vector?
Find its length, then divide each component by it. For (2,3,6)(2, 3, 6) the length is 7, giving (27,37,67)\left(\tfrac{2}{7}, \tfrac{3}{7}, \tfrac{6}{7}\right).
Why is l² + m² + n² always 1?
Because (l,m,n)(l, m, n) is a unit vector, and a unit vector has length 1. It is the 3D Pythagorean theorem divided by the length squared.
Can a direction cosine be negative?
Yes. It has the sign of its component, and a negative value means an angle over 90°90° with that axis.
What is the difference between direction cosines and direction ratios?
Direction ratios are any three numbers in the right proportion, so there are infinitely many sets. Direction cosines are the one set whose squares add to 1.
How many direction cosines does a vector have?
Three in 3D, one for each axis. In 2D it has two: cos⁡α\cos\alpha and sin⁡α\sin\alpha.
Can a vector make 60° with all three axes?
No. That needs 3×(12)2=13 \times \left(\tfrac{1}{2}\right)^2 = 1, but it is only 34\tfrac{3}{4}. The equal angle is about 54.7°54.7°.
✍️ Written By
Annie Charlette Sophia A
Annie Charlette Sophia A
Subject Matter Expert and Curriculum Developer
Annie Charlette Sophia A is a curriculum developer and educator with 13 years of experience teaching students from LKG to Grade 7. Her approach is rooted in the Primary Years Programme (PYP) philosophy, which encourages students to become inquirers, thinkers and confident communicators. She designs engaging, student-centred learning experiences that support both academic understanding and personal growth. Recognised as Innovative Teacher of the Year (2016) from Royale Concorde International School, Bangalore.
LinkedIn
🔬 Reviewed By
Madhukar V
Math Columnist & Analyst
Book a FREE Demo ClassBook Now →