Skip to main content
Engineering LibreTexts

6.04: Direction Cosines

  • Page ID
  • 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:


    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


    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:




    \[α=\frac {1} {||x||}\]

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


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

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


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


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

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

    But the norm of \(e_k\) is 1, so

    \[\cosθ_k=\frac {(x,ek)} {||x||}=\frac {x_k} {||x||}\]

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


    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: