# 2D and 3D coordinate geometry

> IB Mathematics AI HL · Unit 3: Geometry and trigonometry
> Source: https://www.owlsprep.com/study/ib-math-ai-hl-u3-2d-and-3d-coordinate-geometry/

This module covers core coordinate geometry concepts for 2D and 3D space, including distance, midpoint, ratio division, and straight line equations. You will learn to solve intersection and angle problems common in IB AI HL exams.

**Prerequisites:** [Basic vector operations and notation](https://www.owlsprep.com/study/ib-math-ai-hl-u2-vector-basics/)

## Learning objectives

- Calculate distance, midpoint, and sectioned points in 2D and 3D
- Write equations of straight lines in parametric and vector form
- Classify line pairs and test for intersections
- Calculate the acute angle between two lines

## Distance, Midpoint and Section Formula

**Distance between two points** — The shortest straight-line path between two points, derived from Pythagoras' theorem, for both 2D and 3D space.

*Notation:* $d(P_1, P_2)$

*Example:* Distance between $(1,2)$ and $(4,6)$ is $5$ units

All core distance and midpoint formulas extend naturally from 2D to 3D by adding a $z$-coordinate term. The section formula finds the coordinates of a point that divides a line segment in a given ratio.

$$\begin{aligned} \text{2D distance: } d &= \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} \\ \text{3D distance: } d &= \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2} \\ \text{Section ratio } k:m \text{ (internal): } P &= \left(\frac{mx_1 + kx_2}{k+m}, \frac{my_1 + ky_2}{k+m}, \frac{mz_1 + kz_2}{k+m}\right) \end{aligned}$$

**Worked example:** Find the coordinates of the point that divides the segment joining $A(1, 2, -3)$ and $B(3, 4, 5)$ in the ratio $2:1$ internally.

1. Identify input values: $A(x_1,y_1,z_1) = (1, 2, -3)$, $B(x_2,y_2,z_2) = (3, 4, 5)$, ratio $k:m = 2:1$
2. Apply the section formula for each coordinate:
3. $$x = \frac{(1 \times 1) + (2 \times 3)}{2 + 1} = \frac{7}{3}, \quad y = \frac{(1 \times 2) + (2 \times 4)}{3} = \frac{10}{3}, \quad z = \frac{(1 \times -3) + (2 \times 5)}{3} = \frac{7}{3}$$
4. Final answer: the required point is $\left(\frac{7}{3}, \frac{10}{3}, \frac{7}{3}\right)$

> **Exam tip:** Always confirm if the ratio requested is internal or external; external division flips the sign of the ratio term.

## Equations of Straight Lines

**Straight line** — A set of points defined by a fixed initial point (with position vector $\vec{a}$) and a constant direction vector $\mathbf{d}$ that defines the line's orientation. The parameter $t$ scales $\mathbf{d}$ to reach any point on the line.

*Notation:* $\vec{r} = \vec{a} + t\mathbf{d}$

In IB AI HL, you will mostly use parametric vector form for lines in 2D and 3D. To find the direction vector of a line passing through two points $A$ and $B$, calculate $\vec{AB} = B - A$.

**Worked example:** Find the parametric equation of the line passing through $(2, -1, 3)$ and parallel to the vector $2\mathbf{i} - \mathbf{j} + 4\mathbf{k}$.

1. Write the general form for parametric equations:
2. $$x = x_0 + td_x, \quad y = y_0 + td_y, \quad z = z_0 + td_z$$
3. Substitute the fixed point $(x_0, y_0, z_0) = (2, -1, 3)$ and direction vector components $(d_x, d_y, d_z) = (2, -1, 4)$
4. Final parametric equations:
5. $$x = 2 + 2t, \quad y = -1 - t, \quad z = 3 + 4t, \quad t \in \mathbb{R}$$

> **tip**
>
> A direction vector can point in either direction along the line; negating all components of $\mathbf{d}$ does not change the line itself.

## Intersection of Two Lines

Two lines can be: (1) intersecting (meet at exactly one point), (2) parallel (never meet, direction vectors are scalar multiples), (3) coincident (the same line), or (4) skew (only in 3D: non-parallel and never intersect). To check for intersection, set parametric coordinates equal and solve for the parameters.

**Worked example:** Check if lines $L_1: x = 1 + s, y = 2 + 3s, z = -s$ and $L_2: x = 2t, y = 1 + t, z = 1 + 3t$ intersect.

1. Set corresponding coordinates equal to get a system of equations:
2. $$1 + s = 2t, \quad 2 + 3s = 1 + t, \quad -s = 1 + 3t$$
3. Solve the first two equations: rearrange first to get $s = 2t - 1$, substitute into the second:
4. $$2 + 3(2t - 1) = 1 + t \implies 5t = 2 \implies t = \frac{2}{5}, s = -\frac{1}{5}$$
5. Check if the solution satisfies the third equation: Left side $-s = \frac{1}{5}$, Right side $1 + 3(\frac{2}{5}) = \frac{11}{5}$. No match.
6. Conclusion: no consistent solution exists, so lines do not intersect.

**Check your understanding**

If the lines above are not parallel, what are they?

1. What is the classification of the lines in the example?

   - Coincident
   - Skew
   - Perpendicular

   *Why:* Skew lines only exist in 3D space, and are defined as non-parallel lines that never intersect.

## Angle Between Two Lines

The angle between two lines is defined as the smallest (acute) angle between their direction vectors. We use the dot product formula, with an absolute value to ensure we get an acute angle between $0^\circ$ and $90^\circ$.

$$\cos\theta = \frac{|\mathbf{d_1} \cdot \mathbf{d_2}|}{|\mathbf{d_1}| |\mathbf{d_2}|}$$

**Worked example:** Find the angle between two lines with direction vectors $\mathbf{d_1} = \begin{pmatrix}2 \\ 1 \\ -1\end{pmatrix}$ and $\mathbf{d_2} = \begin{pmatrix}1 \\ -1 \\ 1\end{pmatrix}$.

1. Calculate the dot product of the two direction vectors:
2. $$\mathbf{d_1} \cdot \mathbf{d_2} = (2)(1) + (1)(-1) + (-1)(1) = 2 - 1 - 1 = 0$$
3. Substitute into the angle formula: $\cos\theta = \frac{|0|}{|\mathbf{d_1}||\mathbf{d_2}|} = 0$
4. Therefore $\theta = 90^\circ$, so the lines are perpendicular.

> **Exam tip:** Exam questions always ask for the acute angle between two lines, so never leave an obtuse angle as your final answer.

## Common pitfalls

- **Wrong:** Reversing the weights in the section formula for a ratio $AP:PB$
  - Why it fails: You mixed up which point gets which weight, leading to incorrect coordinates
  - Correct: If $P$ divides $AB$ in ratio $k:m$, the coordinates are $P = \frac{m A + k B}{k+m}$, so the weight for $A$ matches the ratio term for $B$
- **Wrong:** Skipping the check for the third coordinate when testing 3D line intersections
  - Why it fails: The first two equations will always have a solution, even for skew lines that do not intersect
  - Correct: Always substitute your solved parameters into all three equations to confirm consistency before concluding lines intersect
- **Wrong:** Forgetting the absolute value in the angle between two lines formula
  - Why it fails: You will calculate the obtuse angle instead of the required acute angle between the lines
  - Correct: Always take the absolute value of the dot product, and give the acute angle as your final answer
- **Wrong:** Assuming all non-intersecting 3D lines are parallel
  - Why it fails: Skew lines are a common case of non-intersecting, non-parallel lines unique to 3D space
  - Correct: Always check if direction vectors are scalar multiples before classifying non-intersecting lines as parallel
- **Wrong:** Subtracting mismatched coordinates when calculating distance
  - Why it fails: You swapped $x$ and $y$ terms, leading to an incorrect distance calculation
  - Correct: Label points clearly, and always subtract $x_1$ from $x_2$ and $y_1$ from $y_2$ before squaring

## Cheatsheet

| Concept | 2D Formula | 3D Formula |
| --- | --- | --- |
| Distance between $P_1, P_2$ | $\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$ | $\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}$ |
| Midpoint of $P_1P_2$ | $\left(\frac{x_1+x_2}{2}, \frac{y_1+y_2}{2}\right)$ | $\left(\frac{x_1+x_2}{2}, \frac{y_1+y_2}{2}, \frac{z_1+z_2}{2}\right)$ |
| Point dividing ratio $k:m$ | $\left(\frac{mx_1+kx_2}{k+m}, \frac{my_1+ky_2}{k+m}\right)$ | $\left(\frac{mx_1+kx_2}{k+m}, \frac{my_1+ky_2}{k+m}, \frac{mz_1+kz_2}{k+m}\right)$ |
| Vector line equation | $\vec{r} = \vec{a} + t\mathbf{d}$ | $\vec{r} = \vec{a} + t\mathbf{d}$ |
| Angle between two lines | $\cos\theta = \frac{\|\mathbf{d_1} \cdot \mathbf{d_2}\|}{\|\mathbf{d_1}\|\|\mathbf{d_2}\|}$ | $\cos\theta = \frac{\|\mathbf{d_1} \cdot \mathbf{d_2}\|}{\|\mathbf{d_1}\|\|\mathbf{d_2}\|}$ |

## What's next

Mastering 2D and 3D coordinate geometry is the foundation for all remaining topics in the IB AI HL Geometry and Trigonometry unit. The skills you learned here, especially working with lines, direction vectors and solving systems for intersections, are directly extended to work with planes in 3D space, finding intersections between lines and planes, and calculating volumes and surface areas of complex 3D shapes. These concepts also transfer directly to vector kinematics, where you will use line equations to model motion of particles in 2D and 3D space.

- [Right triangle trigonometry](https://www.owlsprep.com/study/ib-math-ai-hl-u3-right-triangle-trigonometry/)
- [Non-right triangles: Law of Sines, Law of Cosines, area](https://www.owlsprep.com/study/ib-math-ai-hl-u3-non-right-triangles-law-of/)
- [Unit circle, radian measure, trigonometric identities](https://www.owlsprep.com/study/ib-math-ai-hl-u3-unit-circle-radian-measure-trigonometric/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ib-math-ai-hl-u3-2d-and-3d-coordinate-geometry/
