Skip to content

Vectors and Geometry in 3D Space

In this lesson you’ll extend vectors from 2D to 3D, learn the dot product and cross product, and see how to describe lines and planes in three-dimensional space.

A vector in 3D has three components

v=a,b,c\mathbf{v} = \langle a, b, c \rangle

Its magnitude (length) is

v=a2+b2+c2|\mathbf{v}| = \sqrt{a^2 + b^2 + c^2}

This is just the Pythagorean theorem extended to three dimensions.

The dot product of two vectors gives a scalar (a number, not a vector)

uv=u1v1+u2v2+u3v3\mathbf{u} \cdot \mathbf{v} = u_1 v_1 + u_2 v_2 + u_3 v_3

It’s also equal to

uv=uvcosθ\mathbf{u} \cdot \mathbf{v} = |\mathbf{u}|\,|\mathbf{v}|\cos\theta

where theta is the angle between the vectors. Two vectors are perpendicular (orthogonal) when their dot product is zero.

The cross product of two vectors gives a new vector that is perpendicular to both

u×v=u2v3u3v2,  u3v1u1v3,  u1v2u2v1\mathbf{u} \times \mathbf{v} = \langle u_2 v_3 - u_3 v_2,\; u_3 v_1 - u_1 v_3,\; u_1 v_2 - u_2 v_1 \rangle

The magnitude of the cross product equals the area of the parallelogram formed by the two vectors

u×v=uvsinθ|\mathbf{u} \times \mathbf{v}| = |\mathbf{u}|\,|\mathbf{v}|\sin\theta

The direction follows the right-hand rule: point your fingers along u, curl them toward v, and your thumb points in the direction of u cross v.

A line through point P₀ in the direction of vector v is

r(t)=P0+tv\mathbf{r}(t) = \mathbf{P}_0 + t\,\mathbf{v}

A plane with normal vector n = (a, b, c) passing through point (x₀, y₀, z₀) is

a(xx0)+b(yy0)+c(zz0)=0a(x - x_0) + b(y - y_0) + c(z - z_0) = 0

Example 1: Dot product and angle between vectors

Let u = (1, 2, 3) and v = (4, -1, 2). Find the angle between them.

uv=(1)(4)+(2)(1)+(3)(2)=42+6=8\mathbf{u} \cdot \mathbf{v} = (1)(4) + (2)(-1) + (3)(2) = 4 - 2 + 6 = 8 u=1+4+9=14|\mathbf{u}| = \sqrt{1 + 4 + 9} = \sqrt{14} v=16+1+4=21|\mathbf{v}| = \sqrt{16 + 1 + 4} = \sqrt{21} cosθ=81421=82940.4666\cos\theta = \frac{8}{\sqrt{14}\cdot\sqrt{21}} = \frac{8}{\sqrt{294}} \approx 0.4666 θ=arccos(0.4666)62.2°\theta = \arccos(0.4666) \approx 62.2°

The vectors make an angle of about 62 degrees. Since the dot product is positive, the angle is acute (less than 90 degrees).

Example 2: Cross product

Find u x v for u = (1, 2, 3) and v = (4, -1, 2).

u×v=(2)(2)(3)(1),  (3)(4)(1)(2),  (1)(1)(2)(4)\mathbf{u} \times \mathbf{v} = \langle (2)(2) - (3)(-1),\; (3)(4) - (1)(2),\; (1)(-1) - (2)(4) \rangle =4+3,  122,  18=7,10,9= \langle 4 + 3,\; 12 - 2,\; -1 - 8 \rangle = \langle 7, 10, -9 \rangle

We can verify this is perpendicular to both original vectors by checking the dot products

u(u×v)=(1)(7)+(2)(10)+(3)(9)=7+2027=0\mathbf{u} \cdot (\mathbf{u} \times \mathbf{v}) = (1)(7) + (2)(10) + (3)(-9) = 7 + 20 - 27 = 0 \quad \checkmark v(u×v)=(4)(7)+(1)(10)+(2)(9)=281018=0\mathbf{v} \cdot (\mathbf{u} \times \mathbf{v}) = (4)(7) + (-1)(10) + (2)(-9) = 28 - 10 - 18 = 0 \quad \checkmark

Both dot products are zero, confirming the cross product is perpendicular to both vectors.

The blue arrow is u = (1, 2, 3), the green arrow is v = (4, -1, 2), and the orange arrow is their cross product (7, 10, -9). Notice how the orange vector sticks straight out of the parallelogram formed by u and v. That’s the cross product doing its thing.

Here’s the same thing flattened into 2D (looking at just the x and y components) so you can see the vectors, the parallelogram, and the angle between them without needing to rotate anything.

The 3D version above lets you see how the cross product points out of the plane. The 2D version here shows the parallelogram and angle more clearly. Both views together give you the full picture.

Example 3: Equation of a plane

Find the equation of the plane containing the points A = (1, 0, 0), B = (0, 1, 0), and C = (0, 0, 1).

First, find two vectors in the plane

AB=BA=1,1,0\overrightarrow{AB} = B - A = \langle -1, 1, 0 \rangle AC=CA=1,0,1\overrightarrow{AC} = C - A = \langle -1, 0, 1 \rangle

The normal vector is their cross product

n=AB×AC=(1)(1)(0)(0),  (0)(1)(1)(1),  (1)(0)(1)(1)=1,1,1\mathbf{n} = \overrightarrow{AB} \times \overrightarrow{AC} = \langle (1)(1) - (0)(0),\; (0)(-1) - (-1)(1),\; (-1)(0) - (1)(-1) \rangle = \langle 1, 1, 1 \rangle

Using point A = (1, 0, 0) and normal n = (1, 1, 1)

1(x1)+1(y0)+1(z0)=01(x - 1) + 1(y - 0) + 1(z - 0) = 0 x+y+z=1x + y + z = 1

This makes geometric sense: the plane passes through the three axis intercepts at distance 1 from the origin.

3D vectors and geometry are the backbone of:

  • Game engines use vectors for position, velocity, forces, camera direction, and lighting calculations
  • The cross product computes surface normals, which determine how light bounces off objects
  • The dot product is used for view frustum culling (checking if objects are in front of the camera)
  • Plane equations define collision boundaries, clipping planes, and portals
  • Robotics uses 3D vectors for joint positions and end-effector orientation
The magnitude of $\langle 3, 4, 0 \rangle$ is
Two vectors are perpendicular when their dot product equals
The cross product $\mathbf{u} \times \mathbf{v}$ produces
The equation of a plane with normal $\langle 1, 1, 1 \rangle$ through $(1, 0, 0)$ is
In game development, the cross product is commonly used to compute