---
title: Three-Dimensional Coordinates, Vectors, and the Dot Product
module: Vectors and the Geometry of Space
moduleNumber: 10
lessonNumber: 1
order: 1001
summary: >
  Space needs three coordinates, so we set up the rectangular system, the
  distance formula, and the equation of a sphere. Vectors then package
  magnitude and direction into a single algebraic object with its own
  arithmetic. The dot product turns two vectors into a number that measures the
  angle between them, gives a clean test for orthogonality, and produces the
  projection of one vector onto another.
topics: [Vectors and the Geometry of Space]
sources:
  - book: Stewart
    ref: "Ch. 12 — Vectors and the Geometry of Space; §12.1 Three-Dimensional Coordinate Systems"
  - book: Stewart
    ref: "§12.2 Vectors; §12.3 The Dot Product"
draft: false
---

A point in a plane is fixed by two numbers; a point in space needs three. The
extra coordinate calls for tools to measure distance, name directions, and
multiply geometric quantities. A **coordinate system** — an origin and three
mutually perpendicular axes — names points and measures lengths. A **vector**
records a displacement or a force as one object carrying both size and direction.
The **dot product**, the first of two ways to multiply vectors, recovers the
angle between them.

## Three-dimensional coordinates

Choose a fixed point $O$, the **origin**, and three directed lines through it
that are mutually perpendicular: the $x$-, $y$-, and $z$-axes. The orientation
follows the **right-hand rule**: curl the fingers of your right hand from the
positive $x$-axis toward the positive $y$-axis, and your thumb points along the
positive $z$-axis. The three axes taken in pairs determine the three
**coordinate planes** — the $xy$-, $yz$-, and $xz$-planes — which cut space into
eight **octants**. The first octant is the one where all three coordinates are
positive.

> **Definition (Rectangular coordinates in space).** Every point $P$ in space
> corresponds to exactly one ordered triple $(a, b, c)$ of real numbers, where
> $a$, $b$, $c$ are the signed distances from $P$ to the $yz$-, $xz$-, and
> $xy$-planes respectively. This one-to-one correspondence between points and
> triples in $\mathbb{R}^3 = \{(x,y,z) : x,y,z \in \mathbb{R}\}$ is the
> three-dimensional rectangular coordinate system.

To locate $(a, b, c)$, start at $O$, move $a$ units along the $x$-axis, then $b$
units parallel to the $y$-axis, then $c$ units parallel to the $z$-axis. Dropping
a perpendicular from $P$ to the $xy$-plane gives the **projection** $(a, b, 0)$;
the point together with its projections spans a rectangular box whose diagonal
runs from $O$ to $P$.

$$
% caption: The point P(2,2,2) reached by moving along x, then parallel to y,
% then up parallel to z, with the rectangular box that its coordinates span.
\begin{tikzpicture}[scale=1.1, >=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % projection: (X,Y,Z) -> (X + 0.5 Y, 0.35 Y + Z)
  % axes
  \draw[->, black] (0,0) -- (3.1,0) node[right] {$x$};
  \draw[->, black] (0,0) -- (1.55,1.085) node[right] {$y$};
  \draw[->, black] (0,0) -- (0,3.1) node[above] {$z$};
  \node[anchor=north east] at (0,0) {$O$};
  % foot of P in xy-plane at (2,2,0) -> (3.0,0.7); box guide lines
  \draw[black, dashed] (2,0) -- (3.0,0.7);        % from (2,0,0)
  \draw[black, dashed] (1.0,0.7) -- (3.0,0.7);    % from (0,2,0)
  \draw[black, dashed] (3.0,0.7) -- (3.0,2.7);      % up to P
  \draw[black, dashed] (2,2) -- (3.0,2.7);        % top edges
  \draw[black, dashed] (1.0,2.7) -- (3.0,2.7);
  \draw[black, dashed] (0,2) -- (2,2);
  \draw[black, dashed] (0,2) -- (1.0,2.7);
  % position vector to P (2,2,2) -> (3.0,2.7)
  \draw[acc, very thick, ->] (0,0) -- (3.0,2.7);
  \fill[acc] (3.0,2.7) circle (1.8pt);
  \node[anchor=south west, acc] at (3.0,2.7) {$P(2,2,2)$};
  \fill[black] (3.0,0.7) circle (1.3pt);
  \node[anchor=north west, black] at (3.0,0.7) {$(2,2,0)$};
\end{tikzpicture}
$$

### Distance and spheres

The Pythagorean theorem, applied twice to that box, extends the plane distance
formula to space with no change in form: add one more squared difference.

> **Theorem (Distance in three dimensions).** The distance between
> $P_1(x_1, y_1, z_1)$ and $P_2(x_2, y_2, z_2)$ is
>
> $$
> \abs{P_1 P_2} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}.
> $$

For example, the distance from $P(2, -1, 7)$ to $Q(1, -3, 5)$ is

$$
\abs{PQ} = \sqrt{(1-2)^2 + (-3+1)^2 + (5-7)^2} = \sqrt{1 + 4 + 4} = 3.
$$

A **sphere** is the set of points at a fixed distance $r$ (the radius) from a
fixed center $C(h, k, l)$. Squaring the distance condition $\abs{PC} = r$ gives
the standard equation directly.

> **Definition (Sphere).** The sphere with center $C(h, k, l)$ and radius $r$ is
>
> $$
> (x - h)^2 + (y - k)^2 + (z - l)^2 = r^2.
> $$
>
> Centered at the origin this is $x^2 + y^2 + z^2 = r^2$.

A second-degree equation in $x, y, z$ with equal, positive coefficients on the
squared terms is a sphere; **completing the square** puts it in standard form. Take

$$
x^2 + y^2 + z^2 + 4x - 6y + 2z + 6 = 0.
$$

Group and complete each square:

$$
(x^2 + 4x + 4) + (y^2 - 6y + 9) + (z^2 + 2z + 1) = -6 + 4 + 9 + 1 = 8,
$$

so $(x+2)^2 + (y-3)^2 + (z+1)^2 = 8$, a sphere with center $(-2, 3, -1)$ and
radius $2\sqrt{2}$.

## Vectors

A **vector** records a quantity that has both magnitude and direction —
displacement, velocity, force. Geometrically it is an arrow: a directed segment
whose length is the magnitude and whose heading is the direction. An arrow from
$A$ to $B$ is written $\overrightarrow{AB}$. Two arrows with the same length and
direction are the **same** vector, regardless of where they are drawn; only
length and direction matter.

> **Definition (Vector).** A vector is an object with magnitude and direction,
> represented by any directed line segment of that length and heading. Two
> segments represent equal vectors when one is a parallel translate of the
> other. The **zero vector** $\vec 0$ has length $0$ and no direction.

### Combining vectors

Two operations generate all of vector algebra.

- **Addition** (the Triangle Law): to form $\vec u + \vec v$, place the
  tail of $\vec v$ at the tip of $\vec u$; the sum runs from the tail of
  $\vec u$ to the tip of $\vec v$. Drawing both vectors from a common
  tail and completing the parallelogram gives the same sum along the diagonal
  (the Parallelogram Law), which shows addition is commutative.
- **Scalar multiplication**: for a real number $c$ (a **scalar**), the vector
  $c\vec v$ has length $\abs{c}$ times that of $\vec v$, with the same
  direction if $c > 0$ and the opposite direction if $c < 0$. The **difference**
  is $\vec u - \vec v = \vec u + (-\vec v)$.

$$
% caption: The Triangle Law places v tip-to-tail after u; the Parallelogram Law
% draws both from one point, so the sum is the shared diagonal and u+v = v+u.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % --- triangle law (left) ---
  \begin{scope}
    \draw[very thick, ->] (0,0) -- (2.2,0.5) node[midway, below] {$\mathbf{u}$};
    \draw[black, very thick, ->] (2.2,0.5) -- (3.0,2.2) node[midway, right] {$\mathbf{v}$};
    \draw[acc, very thick, ->] (0,0) -- (3.0,2.2);
    \node[acc] at (1.1,1.65) {$\mathbf{u}+\mathbf{v}$};
    \node[black, anchor=north] at (1.5,-0.55) {Triangle Law};
  \end{scope}
  % --- parallelogram law (right) ---
  \begin{scope}[xshift=5.4cm]
    \draw[very thick, ->] (0,0) -- (2.2,0.5) node[midway, below] {$\mathbf{u}$};
    \draw[black, very thick, ->] (0,0) -- (0.8,1.7) node[midway, left] {$\mathbf{v}$};
    \draw[black, dashed] (2.2,0.5) -- (3.0,2.2);
    \draw[black, dashed] (0.8,1.7) -- (3.0,2.2);
    \draw[acc, very thick, ->] (0,0) -- (3.0,2.2);
    \node[acc, anchor=west] at (1.65,1.45) {$\mathbf{u}+\mathbf{v}$};
    \node[black, anchor=north] at (1.5,-0.55) {Parallelogram Law};
  \end{scope}
\end{tikzpicture}
$$

### Components

Place a vector's tail at the origin; its tip lands at a point, and those
coordinates are the vector's **components**. This turns geometry into
arithmetic.

> **Definition (Components).** The vector $\vec a$ whose representation runs
> from $A(x_1, y_1, z_1)$ to $B(x_2, y_2, z_2)$ has components
>
> $$
> \vec a = \vector{x_2 - x_1,\ y_2 - y_1,\ z_2 - z_1}.
> $$
>
> The representation from the origin to $P(a_1, a_2, a_3)$ is the **position
> vector** of $P$; we use angle brackets $\vector{a_1, a_2, a_3}$ for the
> vector to distinguish it from the point $(a_1, a_2, a_3)$.

The vector from $A(2, -3, 4)$ to $B(-2, 1, 1)$ is
$\vector{-2-2,\ 1+3,\ 1-4} = \vector{-4, 4, -3}$. Its **magnitude** is the length
of any representing segment, given by the distance formula:

$$
\norm{\vec a} = \sqrt{a_1^2 + a_2^2 + a_3^2}.
$$

Arithmetic on vectors is arithmetic on components — add, subtract, and scale
componentwise:

$$
\vec a + \vec b = \vector{a_1 + b_1,\ a_2 + b_2,\ a_3 + b_3},
\qquad
c\vec a = \vector{ca_1,\ ca_2,\ ca_3}.
$$

These operations satisfy the same eight laws as ordinary addition and scaling.

| Property | Statement |
| --- | --- |
| Commutative | $\vec a + \vec b = \vec b + \vec a$ |
| Associative | $\vec a + (\vec b + \vec c) = (\vec a + \vec b) + \vec c$ |
| Additive identity | $\vec a + \vec 0 = \vec a$ |
| Additive inverse | $\vec a + (-\vec a) = \vec 0$ |
| Distributive (over vectors) | $c(\vec a + \vec b) = c\vec a + c\vec b$ |
| Distributive (over scalars) | $(c + d)\vec a = c\vec a + d\vec a$ |

### Standard basis and unit vectors

Three special vectors of length $1$ point along the positive axes:

$$
\hat\imath = \vector{1, 0, 0}, \qquad
\hat\jmath = \vector{0, 1, 0}, \qquad
\hat k = \vector{0, 0, 1}.
$$

Any vector decomposes along them, giving an equivalent notation:
$\vector{a_1, a_2, a_3} = a_1\hat\imath + a_2\hat\jmath + a_3\hat k$. For
instance $\vector{1, -2, 6} = \hat\imath - 2\hat\jmath + 6\hat k$.

A **unit vector** has length $1$. Any nonzero $\vec a$ has a unique unit
vector in its direction, found by dividing out the length:

$$
\hat u = \frac{1}{\norm{\vec a}}\,\vec a = \frac{\vec a}{\norm{\vec a}}.
$$

The vector $2\hat\imath - \hat\jmath - 2\hat k$ has length
$\sqrt{4 + 1 + 4} = 3$, so its direction is captured by the unit vector
$\tfrac{1}{3}(2\hat\imath - \hat\jmath - 2\hat k) = \tfrac{2}{3}\hat\imath - \tfrac{1}{3}\hat\jmath - \tfrac{2}{3}\hat k$.
Because a force carries a magnitude and a direction, it is a vector too, and the
net effect of several forces on a body is their vector sum.

## The dot product

Beyond addition and scaling, vectors admit two products. The first, the **dot
product**, returns a scalar that encodes the angle between the two vectors.

> **Definition (Dot product).** For $\vec a = \vector{a_1, a_2, a_3}$ and
> $\vec b = \vector{b_1, b_2, b_3}$,
>
> $$
> \vec a \cdot \vec b = a_1 b_1 + a_2 b_2 + a_3 b_3.
> $$
>
> The result is a real number, not a vector — hence the alternate name **scalar
> product**.

For example $\vector{2, 4} \cdot \vector{3, -1} = 6 - 4 = 2$, and
$(\hat\imath + 2\hat\jmath - 3\hat k) \cdot (2\hat\jmath - \hat k) = 0 + 4 + 3 = 7$.
The dot product is commutative and distributive, and $\vec a \cdot \vec a = \norm{\vec a}^2$.

### The geometric meaning

The definition is algebraic, but the dot product has a purely geometric reading
in terms of the angle $\theta$ between the two vectors (measured with both tails
at a common point, $0 \le \theta \le \pi$).

> **Theorem (Dot product and angle).** If $\theta$ is the angle between
> $\vec a$ and $\vec b$, then
>
> $$
> \vec a \cdot \vec b = \norm{\vec a}\,\norm{\vec b}\cos\theta.
> $$

The proof applies the Law of Cosines to the triangle with sides $\vec a$,
$\vec b$, and $\vec a - \vec b$:

$$
\norm{\vec a - \vec b}^2 = \norm{\vec a}^2 + \norm{\vec b}^2 - 2\norm{\vec a}\,\norm{\vec b}\cos\theta.
$$

Expanding the left side with
$\norm{\vec a - \vec b}^2 = (\vec a - \vec b) \cdot (\vec a - \vec b) = \norm{\vec a}^2 - 2\,\vec a\cdot\vec b + \norm{\vec b}^2$
and cancelling leaves $\vec a \cdot \vec b = \norm{\vec a}\,\norm{\vec b}\cos\theta$.
Solving for the cosine gives the angle directly.

> **Corollary (Angle between vectors).** For nonzero $\vec a, \vec b$,
>
> $$
> \cos\theta = \frac{\vec a \cdot \vec b}{\norm{\vec a}\,\norm{\vec b}}.
> $$

> **Worked example.** Find the angle between $\vec a = \vector{2, 2, -1}$ and
> $\vec b = \vector{5, -3, 2}$.
>
> The lengths are $\norm{\vec a} = \sqrt{4 + 4 + 1} = 3$ and
> $\norm{\vec b} = \sqrt{25 + 9 + 4} = \sqrt{38}$, and the dot product is
> $\vec a \cdot \vec b = 10 - 6 - 2 = 2$. Then
>
> $$
> \cos\theta = \frac{\vec a \cdot \vec b}{\norm{\vec a}\,\norm{\vec b}}
> = \frac{2}{3\sqrt{38}},
> \qquad
> \theta = \cos^{-1}\!\frac{2}{3\sqrt{38}} \approx 84^\circ.
> $$

### Orthogonality and sign

Since $\norm{\vec a}\,\norm{\vec b} > 0$ for nonzero vectors, the **sign**
of $\vec a \cdot \vec b$ is the sign of $\cos\theta$: positive when the
vectors point in generally the same direction ($\theta < \pi/2$), zero when they
are perpendicular, negative when they point generally apart ($\theta > \pi/2$).
The zero case is the most useful.

> **Theorem (Orthogonality test).** Two vectors $\vec a$ and $\vec b$ are
> orthogonal (perpendicular) if and only if $\vec a \cdot \vec b = 0$.

The vectors $2\hat\imath + 2\hat\jmath - \hat k$ and
$5\hat\imath - 4\hat\jmath + 2\hat k$ are perpendicular because their dot
product is $10 - 8 - 2 = 0$.

$$
% caption: The sign of the dot product tracks the angle: positive for an acute
% angle, zero at a right angle, negative for an obtuse angle.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  % acute
  \begin{scope}
    \draw[very thick, ->] (0,0) -- (1.9,0) node[right] {$\mathbf{a}$};
    \draw[black, very thick, ->] (0,0) -- (1.4,1.3) node[above] {$\mathbf{b}$};
    \draw[black] (0.55,0) arc (0:43:0.55);
    \node[anchor=south, black] at (0.95,-1.05) {$\mathbf{a}\cdot\mathbf{b}>0$};
    \node[anchor=south, black, font=\scriptsize] at (0.95,-1.55) {acute};
  \end{scope}
  % right
  \begin{scope}[xshift=4.4cm]
    \draw[very thick, ->] (0,0) -- (1.9,0) node[right] {$\mathbf{a}$};
    \draw[black, very thick, ->] (0,0) -- (0,1.7) node[above] {$\mathbf{b}$};
    \draw[black] (0.3,0) -- (0.3,0.3) -- (0,0.3);
    \node[anchor=south, black] at (0.95,-1.05) {$\mathbf{a}\cdot\mathbf{b}=0$};
    \node[anchor=south, black, font=\scriptsize] at (0.95,-1.55) {right angle};
  \end{scope}
  % obtuse
  \begin{scope}[xshift=8.8cm]
    \draw[very thick, ->] (0,0) -- (1.9,0) node[right] {$\mathbf{a}$};
    \draw[black, very thick, ->] (0,0) -- (-1.1,1.4) node[above left] {$\mathbf{b}$};
    \draw[black] (0.55,0) arc (0:128:0.55);
    \node[anchor=south, black] at (0.4,-1.05) {$\mathbf{a}\cdot\mathbf{b}<0$};
    \node[anchor=south, black, font=\scriptsize] at (0.4,-1.55) {obtuse};
  \end{scope}
\end{tikzpicture}
$$

The angles $\alpha, \beta, \gamma$ that $\vec a$ makes with the positive
axes are its **direction angles**, and their cosines — the **direction cosines**
— are the components of the unit vector $\vec a/\norm{\vec a}$: applying
the corollary with $\vec b = \hat\imath, \hat\jmath, \hat k$ gives
$\cos\alpha = a_1/\norm{\vec a}$, and likewise for the others.

## Projections

How much of $\vec b$ lies along the direction of $\vec a$? Drop a
perpendicular from the tip of
$\vec b$ onto the line through $\vec a$; the shadow it casts is the
**vector projection** $\operatorname{proj}_{\vec a}\vec b$, and its signed length is the
**scalar projection** $\operatorname{comp}_{\vec a}\vec b$.

$$
% caption: The scalar projection of b onto a is the signed length of the
% perpendicular shadow of b along a; the vector projection is that length times
% the unit vector of a.
\begin{tikzpicture}[scale=1.2, >=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{4A6FA5}
  \coordinate (P) at (0,0);
  \coordinate (Q) at (3.4,0);
  \coordinate (R) at (2.2,1.7);
  \coordinate (S) at (2.2,0);
  \draw[very thick, ->] (P) -- (Q) node[right] {$\mathbf{a}$};
  \draw[black, very thick, ->] (P) -- (R) node[above right] {$\mathbf{b}$};
  \draw[black, dashed] (R) -- (S);
  \draw[black] (2.0,0) -- (2.0,0.2) -- (2.2,0.2);
  \draw[acc, line width=1.6pt] (P) -- (S);
  \node[acc, anchor=north] at (1.1,-0.08) {$\operatorname{proj}_{\mathbf{a}}\mathbf{b}$};
  \draw[black] (0.5,0) arc (0:38:0.5);
  \node[anchor=south, black, font=\scriptsize] at (2.2,-0.62) {scalar projection $\operatorname{comp}_{\mathbf{a}}\mathbf{b}$};
\end{tikzpicture}
$$

Since the scalar projection is $\norm{\vec b}\cos\theta$ and
$\vec a \cdot \vec b = \norm{\vec a}\,\norm{\vec b}\cos\theta$,
dividing by $\norm{\vec a}$ isolates it. The vector projection is that scalar
times the unit vector of $\vec a$.

> **Definition (Projections).** The scalar and vector projections of
> $\vec b$ onto $\vec a$ are
>
> $$
> \operatorname{comp}_{\vec a}\vec b = \frac{\vec a \cdot \vec b}{\norm{\vec a}},
> \qquad
> \operatorname{proj}_{\vec a}\vec b = \parens{\frac{\vec a \cdot \vec b}{\norm{\vec a}}}\frac{\vec a}{\norm{\vec a}} = \frac{\vec a \cdot \vec b}{\norm{\vec a}^2}\,\vec a.
> $$

> **Worked example.** Find the scalar and vector projections of
> $\vec b = \vector{1, 1, 2}$ onto $\vec a = \vector{-2, 3, 1}$.
>
> The length is $\norm{\vec a} = \sqrt{4 + 9 + 1} = \sqrt{14}$ and the dot
> product is $\vec a \cdot \vec b = -2 + 3 + 2 = 3$. The scalar projection is
> therefore
>
> $$
> \operatorname{comp}_{\vec a}\vec b = \frac{\vec a \cdot \vec b}{\norm{\vec a}} = \frac{3}{\sqrt{14}}.
> $$
>
> Multiplying the unit vector of $\vec a$ by this scalar gives the vector
> projection:
>
> $$
> \operatorname{proj}_{\vec a}\vec b = \frac{\vec a \cdot \vec b}{\norm{\vec a}^2}\,\vec a = \frac{3}{14}\,\vector{-2, 3, 1} = \vector{-\tfrac{3}{7},\ \tfrac{9}{14},\ \tfrac{3}{14}}.
> $$

### Work as a dot product

Projection defines physical **work**. When a constant
force $\vec F$ moves an object along a displacement $\vec D$, only the
component of $\vec F$ along $\vec D$ does work. That component is a scalar
projection, so the work is the dot product

$$
W = \parens{\norm{\vec F}\cos\theta}\norm{\vec D} = \vec F \cdot \vec D.
$$

> **Worked example.** A force of magnitude $70\,\text{N}$ pulls a wagon at
> $35^\circ$ above the horizontal, moving it $100\,\text{m}$ along the ground.
> How much work does the force do?
>
> Only the horizontal component of the force moves the wagon, so the work is the
> dot product $W = \norm{\vec F}\,\norm{\vec D}\cos\theta$:
>
> $$
> W = (70)(100)\cos 35^\circ \approx 5734\,\text{J}.
> $$
>
> The vertical component, which lifts against gravity but not along the motion,
> contributes nothing.
