4.4: Direction Cosines

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Unit Vectors

Corresponding to every vector $$x$$ is a unit vector $$u_x$$ pointing in the same direction as $$x$$. The term unit vector means that the norm of the vector is 1:

$||u_x||=1 \nonumber$

The question is, given $$x$$, how can we find $$u_x$$? The first part of the answer is that $$u_x$$ will have to be a positive scalar multiple of $$x$$ in order to point in the same direction as $$x$$, as shown in this Figure. Thus

$u_x=αx \nonumber$

But what is $$α$$? We need to choose $$α$$ so that the norm of $$u_x$$ will be 1:

$||ux||=1 \nonumber$

$|αx||=1 \nonumber$

$|α|||x||=1 \nonumber$

$α=\frac {1} {||x||} \nonumber$

We have dropped the absolute value bars on $$α$$ because $$||x||$$ is positive. The $$α$$ that does the job is 1 over the norm of $$x$$. Now we can write formulas for $$u_x$$ in terms of $$x$$ and $$x$$ in terms of $$u_x$$:

$u_x=\frac 1 {||x||}x \nonumber$

$x=||x||u_x \nonumber$

So the vector $$x$$ is its direction vector $$u_x$$, scaled by its Euclidean norm.

Unit Coordinate Vectors

There is a special set of unit vectors called the unit coordinate vectors. The unit coordinate vector $$e_i$$ is a unit vector in $$∇^n$$ that points in the positive direction of the $$i^{\mathrm{th}}$$ coordinate axis. The Figure shows the three unit coordinate vectors in $$∇^3$$.

For three-dimensional space, $$R^3$$, the unit coordinate vectors are

$e_1=\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix},e_2=\begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix}, e_3=\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} \nonumber$

More generally, in n-dimensional space, there are $$n$$ unit coordinate vectors given by

You should satisfy yourself that this definition results in vectors with a norm of l.

Exercise $$\PageIndex{1}$$

Find the norm of the vector au where $$u$$ is a unit vector.

Exercise $$\PageIndex{2}$$

Find the unit vector $$u_x$$ in the direction of

1. $$x=\begin{bmatrix} 3 \\ 4 \end{bmatrix}$$
2. $$x=\begin{bmatrix} 3 \\ 6 \\ −2 \end{bmatrix}$$
3. $$x=\begin{bmatrix} 1 \\ −1 \\ 1 \\ −1 \end{bmatrix}$$

Direction Cosines

We often say that vectors “have magnitude and direction.” This is more or less obvious from "Linear Algebra: Vectors", where the three-dimensional vector $$x$$ has length $$\sqrt{x^2_1+x^2_2+x^2_3}$$ and points in a direction defined by the components $$x_1$$, $$x_2$$, and $$x_3$$. It is perfectly obvious from Equation $$\PageIndex{8}$$ where $$x$$ is written as $$x=||x||\,u_x$$. But perhaps there is another representation for a vector that places the notion of magnitude and direction in even clearer evidence.

The Figure below shows an arbitrary vector $$x∈R^3$$ and the three-dimensional unit coordinate vectors $$e_1,e_2,e_3$$. The inner product between the vector $$x$$ and the unit vector $$e_k$$ just reads out the $$k^\mathrm{th}$$ component of $$x$$:

$(x,e_k)=(e_k,x)=x_k \nonumber$

Since this is true even in $$R^n$$, any vector $$x∈R^n$$ has the following representation in terms of unit vectors:

$x=(x,e_1)e_1+(x,e_2)e_2+⋯+(x,e_n)e_n \nonumber$

Let us now generalize our notion of an angle $$θ$$ between two vectors to $$R^n$$ as follows:

$\cosθ=\frac {(x,y)} {||x||||y||} \nonumber$

The celebrated Cauchy-Schwarz inequality establishes that $$−1−≤ \cos θ≤1$$. With this definition of angle, we may define the angle $$θ_k$$ that a vector makes with the unit vector $$e_k$$ to be

$\cosθ_k=\frac {(x,e_k)} {||x||||e_k||} \nonumber$

But the norm of $$e_k$$ is 1, so

$\cosθ_k=\frac {(x,e_k)} {||x||}=\frac {x_k} {||x||} \nonumber$

When this result is substituted into the representation of x in Equation $$\PageIndex{11}$$, we obtain the formula

$x=||x||\cosθ_1e_1+||x||\cosθ_2e_2+⋯+||x||\cosθ_ne_n=||x||(\cosθ_1e_1+\cosθ_2e_2+⋯+\cosθ_ne_n) \nonumber$

This formula really shows that the vector $$x$$ has “magnitude” $$||x||$$ and direction $$(θ_1,θ_2,...,θ_n)$$ and that the magnitude and direction are sufficient to determine $$x$$. We call ($$\cosθ_1, \cos θ_2,..., \cos θ_n$$) the direction cosines for the vector $$x$$. In the three-dimensional case, they are illustrated in the Figure above.

Exercise $$\PageIndex{3}$$

Show that Equation $$\PageIndex{12}$$ agrees with the usual definition of an angle in two dimensions.

Exercise $$\PageIndex{4}$$

Find the cosine of the angle between $$x$$ and $$y$$ where

1. $$x=\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}\;y=\begin{bmatrix} 2 \\ 2 \\ 2 \end{bmatrix}$$
2. $$x=\begin{bmatrix} 1 \\ −1 \\ 1 \\ −1 \end{bmatrix}\;y=\begin{bmatrix} −1 \\ 0 \\ 1 \\ 0 \end{bmatrix}$$
3. $$x=\begin{bmatrix} 2 \\ 1 \\ −2 \end{bmatrix}\;y=\begin{bmatrix} 4 \\ 2 \\ −4 \end{bmatrix}$$

If we compare Equation $$\PageIndex{8}$$ and Equation $$\PageIndex{15}$$ we see that the direction vector $$u_x$$ is composed of direction cosines:

$u_x=\cosθ_1e_1+\cosθ_2e_2+⋯+\cosθ_ne_n=\begin{bmatrix} \cosθ_1\\cosθ_2\\ ... \\ \cosθ_n \end{bmatrix} \nonumber$

With this definition we can write Equation $$\PageIndex{15}$$ compactly as

Here $$x$$ is written as the product of its magnitude $$||x||$$ and its direction vector $$u_x$$. Now we can give an easy procedure to find a vector's direction angles:

1. find $$||x||$$
2. calculate $$u_x=\frac {x} {||x||}$$
3. take the arc cosines of the elements of $$u_x$$

Step 3 is often unnecessary; we are usually more interested in the direction vector (unit vector) $$u_x$$. Direction vectors are used in materials science in order to study the orientation of crystal lattices and in electromagnetic field theory to characterize the direction of propagation for radar and microwaves. You will find them of inestimable value in your courses on electromagnetic fields and antenna design.

Exercise $$\PageIndex{5}$$

Sketch an arbitrary unit vector $$u∈R^3$$. Label the direction cosines and the components of $$u.S$$

Exercise $$\PageIndex{6}$$

Compute the norm and the direction cosines for the vector $$x=\begin{bmatrix} 4\\2\\6 \end{bmatrix}$$.

Exercise $$\PageIndex{7}$$

Prove that the direction cosines for any vector satisfy the equality

$\cos^2θ_1+\cos^2θ_2+⋯+\cos^2θ_n=1 \nonumber$
What does this imply about the number of scalars needed to determine a vector $$x∈R^n$$ ?

Exercise $$\PageIndex{8}$$

Astronomers use right ascension, declination, and distance to locate stars. On Figure these are, respectively, $$−φ,\frac π 2 −θ_3, \mathrm{and} ||x||$$. Represent $$x=(x_1,x_2,x_3)$$ in terms of $$φ,θ3, \mathrm{and} ||x||$$ only. (That is, find equations that give $$φ,θ_3, \mathrm{and} ||x||$$ in terms of $$x_1$$,$$x_2$$, and $$x_3$$, and find equations that give $$x_1$$,$$x_2$$, and $$x_3$$ in terms of $$φ,θ_3, \mathrm{and} ||x||$$.)

Exercise $$\PageIndex{9}$$

(MATLAB) Write a MATLAB function that accepts any vector $$x∈R^n$$ and computes its norm and direction cosines. Make $$x$$ an input variable, and make $$||x||$$ and $$u_x$$ output variables.

Exercise $$\PageIndex{10}$$

Let $$x$$ and $$y$$ denote two vectors in $$R^n$$ with respective direction cosines $$(\cosθ_1,\cosθ_2,...,\cosθ_n)$$ and ($$\cosφ_1,\cosφ_2,...,\cosφ_n)$$. Prove that $$ψ$$, the angle between $$x$$ and $$y$$, is

$\cosψ=\cosθ_1\cosφ_1+\cosθ_2\cosφ_2+⋯+\cosθ_n\cosφ_n \nonumber$.
Specialize this result to $$R^2$$ for insight.

Exercise $$\PageIndex{11}$$

Compute the angle between the vectors $$x=\begin{bmatrix} 2 \\ 3 \\ 0 \end{bmatrix}$$ and $$\begin{bmatrix} 2 \\ 3 \\ 1 \end{bmatrix}$$. Sketch the result.

This page titled 4.4: Direction Cosines is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by Louis Scharf (OpenStax CNX) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.