# Voronoi diagrams

> Math: Applications and Interpretation (IB Mathematics: Applications and Interpretation SL and HL) · Geometry and trigonometry. A free chapter of Atlas, the interactive visual textbook: https://atlasclass.app/math-ai/ibvoronoi/. On the site each page sits beside an interactive 3D figure; here it is the words and the math (LaTeX) alone.

## Chapter 8 · Voronoi diagrams

*who is nearest*

Five towns share a 12 km by 10 km map. For every place on it, which town is nearest?

Picture a wave leaving every town at the same moment and the same speed. Each place belongs to the first wave that reaches it. Where two waves meet, a place is equally far from two towns: those meeting lines are the red **edges**, and they split the map into one **cell** per town.

That is a **Voronoi diagram**. This chapter builds one from straight-line geometry: distance, midpoint and gradient, then the perpendicular bisector. Then it reads the diagram: adding a town, estimating values by nearest neighbour, and finding the place furthest from every town.

## 3.1 · IB Math AI · Distance, midpoint and gradient

*two towns, A and C*

Town A is at $(2, 2)$ and town C at $(10, 7)$, in kilometres. Three facts about the segment between them do all the work in this chapter.

$$d = \sqrt{8^2 + 5^2} = \sqrt{89} \approx 9.434$$

The **midpoint** averages the coordinates: $M = \left(\frac{2 + 10}{2}, \frac{2 + 7}{2}\right) = (6, 4.5)$. The **gradient** is rise over run: $m = \frac{7 - 2}{10 - 2} = 0.625$.

A line **perpendicular** to AC has gradient $-\frac{1}{m} = -1.6$: the two gradients multiply to $-1$. In the figure a red line turns about $M$; the readout shows the product of the gradients reaching $-1$ as it lands at right angles to AC.

## 3.5 · IB Math AI · Perpendicular bisectors

*the line of equal distances*

The **perpendicular bisector** of AC is the line through its midpoint at right angles to it. Every point on it is the same distance from A as from C, and every point off it is nearer to one of them.

Through $M(6, 4.5)$ with gradient $-1.6$, the point–gradient form gives

$$y - 4.5 = -1.6(x - 6) \quad\Rightarrow\quad y = -1.6x + 14.1$$

Check a point on it, $(4, 7.7)$: its distance to A is $\sqrt{4 + 32.49} \approx 6.041$ km, and to C $\sqrt{36 + 0.49} \approx 6.041$ km. Equal, as the blue arms show wherever the point slides.

So the bisector splits the map in two: the side containing A is nearer to A. With only two towns it would be the whole Voronoi diagram.

## 3.6 · IB Math AI · Sites, edges, vertices and cells

*the parts of a Voronoi diagram*

With more towns, each town’s **cell** is the region nearer to it than to any other. The towns are the **sites**.

A cell is cut out by the perpendicular bisectors between its site and the others, keeping the side nearer its own site each time. The pieces of bisector left over are the **edges**; a point on an edge is equally far from the two sites either side. The points where edges meet, equally far from three sites, are the **vertices**.

This diagram has 5 sites, 8 edges and 4 vertices. Cells are always convex polygons; those at the outside would run on for ever, so the map’s border closes them.

To find which town is nearest to a place, find the cell it is in. In the figure the red point wanders the map and the shaded cell follows it: its nearest town is always that cell’s site.

## 3.6 · IB Math AI · Finding a vertex

*where three cells meet*

A vertex is equally far from three sites, so it lies on all three of their perpendicular bisectors. Two are enough to find it.

The cells of A, B and E meet at one vertex. The bisector of AB is $y = 6x - 28.5$ and the bisector of AE is $y = -\tfrac{4}{3}x + \tfrac{53}{6}$. Solving them together (by hand or on the calculator):

$$6x - 28.5 = -\tfrac{4}{3}x + \tfrac{53}{6}$$

so $x = \tfrac{56}{11} \approx 5.09$ and $y = \tfrac{45}{22} \approx 2.05$. Its distance to each of A, B and E is $\approx 3.091$ km. So the vertex is the centre of the circle through the three towns, and no other town lies inside that circle: if one did, the vertex would be in that town’s cell instead.

## 3.6 · IB Math AI · Adding a site

*a new cell carved out of its neighbours*

A sixth town, F, is built at $(10, 3)$. The diagram does not start again: F takes a piece from each neighbouring cell.

Draw the perpendicular bisectors between F and the sites whose cells it lands near, B, C and E: for BF $y = -x + 11$, for CF $y = 5$, and for EF $y = 2x - 12$.

The region on F’s side of all of them is F’s cell. Rub out the old edges inside it, and the new edges are the pieces of these bisectors around it. F’s cell covers $15.42$ km²: B loses 9.83 km², C 4.75 km² and E 0.83 km². A and D, whose cells it doesn’t touch, are unchanged.

That is the exam method: decide which cells the new site affects, draw only those bisectors, then redraw the boundary.

## 3.6 · IB Math AI · Nearest-neighbour interpolation

*estimating between the data*

Each town has a weather station. To estimate the rainfall somewhere without one, use the value of the **nearest** station: the site of the cell the place is in.

Last month the stations recorded A 62 mm, B 48 mm, C 85 mm, D 110 mm, E 74 mm. A farm at $(9, 9)$ lies in C’s cell, so its estimate is 85 mm.

Raised to their values, the cells make a surface of flat steps. It is quick and needs no formula, but the estimate jumps at every edge and ignores the other stations: a farm just across an edge from C gets a quite different value. Better methods weight several stations by distance; nearest neighbour is the simplest, and the one a Voronoi diagram gives for free.

## 3.6 · IB Math AI · The toxic waste dump problem

*as far as possible from everyone*

Where on the map should a waste dump go, to be as far as possible from the nearest town?

Inside a cell, moving away from its site helps until you reach an edge, then along the edge until you reach a vertex. So the best place is a vertex: the centre of the **largest empty circle**, a circle through three towns with none inside.

The 4 vertices are $(5.09, 2.05)$, 3.09 km; $(2.5, 5.5)$, 3.54 km; $(9, 4)$, 3.16 km; $(7.43, 7.14)$, 2.58 km from their nearest towns. The largest is at $(2.5, 5.5)$, $\sqrt{12.5} \approx 3.536$ km from A, D, E.

A real search also checks the boundary: the corner $(0, 10)$ is 5.385 km from D, its nearest town, further than any vertex. IB questions restrict the answer to the vertices inside the region; say so when you use the method.

## 3.6 · IB Math AI · Reading a diagram: areas and uses

*catchments, hospitals and phone masts*

A cell’s area is the area each site serves. E’s cell has vertices $(2.5, 5.5)$, $(5.09, 2.05)$, $(9, 4)$, $(7.43, 7.14)$.

Its area, split into triangles from E (or with the shoelace formula on the vertices): $\approx 18.32$ km², the smallest of the five. The five cells together cover the whole $12 \times 10 = 120$ km² map.

The same picture answers many questions about “nearest”: which hospital an ambulance should go to, which phone mast a phone connects to, which school’s catchment a house is in, where a new shop would take the most customers. In 1854 John Snow drew the streets of London nearer, on foot, to the Broad Street pump than to any other; the cholera deaths were clustered inside it.

Exam questions ask you to find a bisector’s equation, add a site, interpolate, find a cell’s area, or place the dump. Each is one of the pages before.

---

Read it with the figures, and practice it graded as you go: https://atlasclass.app/math-ai/ibvoronoi/
