Skip to main content
Engineering LibreTexts

4.4: Direction Cosines

  • Page ID
    9971
  • \( \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}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    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 \]

    A Cartesian graph with a line originating at the origin and extending up and to the left. The line actually consist of two arrows in a line. The first arrow ends in a point. Below the point is the expression U_x. From the arrow point to the y axis is an arch. The arch ends at the y axis and to the left of the point where it end is the number 1. Another proceeds from where the previous arrow ended and proceeds along the same slope, ends in an point and up and to the left of the point is an X.
    Figure \(\PageIndex{1}\): The Unit Vector \(u_x\)

    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\).

    Figure 2 is a three-dimensional graph describing the coordinate vectors. The axis pointing out towards the screen is labeled x_1, the axis pointing to the right is labeled x_2 and the axis pointing up is labeled x_3. There are three vectors in the diagram, and each follow an axis, are labeled with an e and the corresponding subscript of the axis on which they are drawn, and are of length 1.
    Figure \(\PageIndex{2}\): Unit Coordinate Vectors in R 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

    Figure 3 is a vector e_1 with arrows pointing to a specific entry in the vector, designating the i-th element, and to the last entry in the vector, designating a total of n elements.
    Figure \(\PageIndex{3}\)

    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 \]

    Figure four is a three-dimensional graph with four vectors and measured angles between the vectors. Along the axis that moves towards the screen is the vector e_1, [1 0 0]. Along the axis moving up the page is the vector e_3, [0 0 1]. The angle between e_1 and e_3 is labeled θ_1. A third vector is drawn along the axis that moves to the right, and is labeled e_2 [0 1 0]. The angle between e_2 and e_3 is labeled θ_2. A fourth and final vector is drawn in the positive e_1 e_2 and e_3 directions, and is labeled x. The magnitude of x is labeled as ||x||. The angle between x and e_3 is labeled as θ_3. The angle between the projection of x onto the e_1 e_2 axis and the vector e_1 is labeled Φ.
    Figure \(\PageIndex{4}\): The Three-Dimensional Unit Vectors

    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.