The Equation of a Voronoi Edge

Midpoint, negative reciprocal, and out it comes.

An edge is a perpendicular bisector

Site A is at (1, 2) and site B is at (5, 4). The edge between their Voronoi cells is made of the points equally far from A and from B, and those points form the perpendicular bisector of AB.

A straight line is fixed by one point on it and its gradient. The bisector passes through the midpoint of AB, and it crosses AB at a right angle, so its gradient comes from the gradient of AB.

012345678012345678AB

The two sites, A at (1, 2) and B at (5, 4), on axes from 0 to 8.

The midpoint

The midpoint averages the coordinates. Add the two x-coordinates and halve: 1 + 5 = 6, and half of 6 is 3. Do the same with the y-coordinates: 2 + 4 = 6, and half of 6 is 3. The midpoint is (3, 3). Call it M.

M is on the edge. It is √(2² + 1²) = √5 ≈ 2.24 from A, and √(2² + 1²) = √5 from B as well.

0123456780123456782.242.24ABM

M at (3, 3) is 2.24 from A and 2.24 from B.

The perpendicular gradient

The gradient of AB is the rise over the run: (4 − 2) ÷ (5 − 1) = 2/4 = 1/2.

Two lines are perpendicular when their gradients multiply to −1. Turning a line through a right angle turns a step of 2 across and 1 up into a step of 1 across and 2 down, so a gradient of 1/2 becomes −2. In general the perpendicular gradient is the negative reciprocal: −1 ÷ 1/2 = −2. Check: 1/2 × (−2) = −1.

The equation

The line through (3, 3) with gradient −2 is y − 3 = −2(x − 3). Expanding the bracket gives y − 3 = −2x + 6, so y = −2x + 9. It can also be written 2x + y = 9.

012345678012345678ABM

The edge y = −2x + 9, in gold, through M at (3, 3). It crosses AB at a right angle.

Checking with distances

Any point on the line should be equally far from A and B. Take x = 4: then y = −8 + 9 = 1, the point (4, 1). Its squared distance from A is 3² + 1² = 10, and from B it is 1² + 3² = 10, so both distances are √10 ≈ 3.16.

A point off the line fails the test. The point (6, 6) has −2 × 6 + 9 = −3, not 6, so it is not on the edge. Its squared distances are 5² + 4² = 41 from A and 1² + 2² = 5 from B, so it is nearer to B.

0123456780123456783.163.16ABP

P at (4, 1) lies on the gold edge, and it is 3.16 from A and 3.16 from B.

The same line from the distances

The edge can also be found straight from its meaning. A point (x, y) is equally far from A and B when its squared distances are equal: (x − 1)² + (y − 2)² = (x − 5)² + (y − 4)².

Expand both sides: x² − 2x + 1 + y² − 4y + 4 = x² − 10x + 25 + y² − 8y + 16. The x² and y² cancel, leaving −2x − 4y + 5 = −10x − 8y + 41. Collect the terms: 8x + 4y = 36, and dividing by 4 gives 2x + y = 9, the same line.

Which side is which

The edge divides the plane into the two cells. Put A into 2x + y: 2 + 2 = 4, which is less than 9. Put B in: 10 + 4 = 14, more than 9. So A’s cell is where 2x + y < 9, and B’s cell is where 2x + y > 9.

In the frame from 0 to 8, the edge meets the x-axis where y = 0 and x = 4.5, and the top of the frame, y = 8, at x = 0.5.

012345678012345678AB

A’s cell, in gold, is where 2x + y < 9. Its edge runs from (4.5, 0) to (0.5, 8).

Sites level, or one above the other

When the two sites are level, AB has gradient 0, and 0 has no reciprocal. The bisector is then vertical, through the midpoint. For A at (1, 2) and C at (7, 2), the midpoint is (4, 2) and the edge is x = 4.

When one site is directly above the other, AB is vertical and the bisector is horizontal: for (2, 1) and (2, 7) the edge is y = 4.

The usual mistakes

Using the gradient of AB for the edge. A line through M with gradient 1/2 runs alongside AB, not across it.

Flipping the fraction without changing the sign. A gradient of 2 is not perpendicular to 1/2, because 1/2 × 2 = 1, not −1.

Subtracting the coordinates instead of averaging them. (5 − 1, 4 − 2) = (4, 2) is the step from A to B, not the midpoint.

Drawing the line through A or B instead of through the midpoint. The edge must be equally far from both sites, so it passes through M.

Schools and fire stations

In the first application below, the zone boundary between two schools is written as y = mx + c, and a road is followed across it. In the second, two edges between three fire stations are found and solved together, and their meeting point is equally far from all three.

Worked example: The Zone Boundary Between Two Elementary Schools, and Where a Straight Road Crosses It

Question A town plans to zone each home to the nearer of its two elementary schools by straight-line distance. On the town map, in kilometers, school A is at (1, 2) and school B is at (7, 6). (a) Find the equation of the zone boundary in the form y = mx + c. (b) A straight road runs along y = 1. At what point on the road does the zone change, and to which school are the homes on the road east of that point zoned?

  1. 1.The midpoint of AB is (1 + 72, 2 + 62) = (4, 4).

    2468246AB(4, 4)midpoint of AB: (4, 4)
    2468246AB(4, 4)midpoint of AB: (4, 4)
    The boundary passes through the midpoint of AB, (4, 4).
  2. 2.The gradient of AB is 6 − 27 − 1 = 46 = 23. The boundary is perpendicular to AB, so its gradient is the negative reciprocal, −32. Check: 23 × (−32) = −1.

    2468246AB(4, 4)gradient of AB = 4/6 = 2/3perpendicular gradient = −3/2
    2468246AB(4, 4)gradient of AB = 4/6 = 2/3perpendicular gradient = −3/2
    AB has gradient 23, so the boundary, at right angles to it, has gradient −32.
  3. 3.(a) The line through (4, 4) with gradient −32 is y − 4 = −32(x − 4), so y = −32x + 6 + 4, which is y = −32x + 10.

    2468246AB(4, 4)boundaryy − 4 = −3/2 (x − 4)y = −3/2 x + 10
    2468246AB(4, 4)boundaryy − 4 = −3/2 (x − 4)y = −3/2 x + 10
    (a) The boundary is y = −32x + 10.
  4. 4.Substitute the road, y = 1: 1 = −32x + 10, so 32x = 9 and x = 6. The zone changes at (6, 1). Check: (6, 1) is √52 + 12 = √26 km from A and √12 + 52 = √26 km from B.

    2468246ABroad y = 1y = −1.5x + 10(6, 1)1 = −3/2 x + 10, so x = 6(6, 1) is √26 from A and from B
    2468246ABroad y = 1y = −1.5x + 10(6, 1)1 = −3/2 x + 10, so x = 6(6, 1) is √26 from A and from B
    On the road y = 1: 1 = −32x + 10 gives x = 6, so the zone changes at (6, 1).
  5. 5.(b) Test a home east of that point, at (8, 1): it is √72 + 12 = √50 km from A and √12 + 52 = √26 km from B, so it is nearer B. The homes on the road east of (6, 1) are zoned to B, even though A is only 1 km from the road and B is 5 km from it.

    2468246ABroad y = 1(8, 1)y = −1.5x + 10(6, 1)(8, 1): √50 from A, √26 from Beast of (6, 1): zoned to B
    2468246ABroad y = 1(8, 1)y = −1.5x + 10(6, 1)(8, 1): √50 from A, √26 from Beast of (6, 1): zoned to B
    (b) East of (6, 1) the road is in B's zone: (8, 1) is √26 km from B and √50 km from A.

Answer: (a) y = −32x + 10. (b) At (6, 1); the homes east of it are zoned to B

Common mistakes

  • Using the gradient of AB, 23, for the boundary. That line runs through the midpoint parallel to AB; the boundary crosses AB at a right angle, so its gradient is −32.
  • Zoning the homes east of (6, 1) to A because A is only 1 km from the road. Each home compares its own two distances, and (8, 1) is √50 km from A but only √26 km from B.

More voronoi diagrams problems, worked step by step →

Worked example: Three Fire Stations in a County: Two Edges Between Their Response Areas, and the Point Where They Meet

Question A county is the rectangle 0 ≤ x ≤ 14, 0 ≤ y ≤ 14, in kilometers, and its fire stations are A at (1, 1), B at (13, 7) and C at (5, 13). A first plan sends each call to the nearest station by straight-line distance. (a) Find the equations of the edge between A's and B's areas and of the edge between B's and C's areas, each in the form ax + by = c with whole numbers. (b) Find the point where the two edges meet, and its straight-line distance from each station.

  1. 1.The edge between A and B: the midpoint of AB is (7, 4) and AB has gradient 612 = 12, so the edge has gradient −2: y − 4 = −2(x − 7), which is 2x + y = 18.

    48124812ABC(7, 4)AB: midpoint (7, 4), gradient 1/2edge: gradient −2, so 2x + y = 18
    48124812ABC(7, 4)AB: midpoint (7, 4), gradient 1/2edge: gradient −2, so 2x + y = 18
    The edge between A and B passes through (7, 4) with gradient −2: 2x + y = 18.
  2. 2.The edge between B and C: the midpoint of BC is (9, 10) and BC has gradient 13 − 75 − 13 = −34, so the edge has gradient 43: y − 10 = 43(x − 9). Multiply both sides by 3: 3y − 30 = 4x − 36, which is 4x − 3y = 6.

    48124812ABC2x + y = 18(9, 10)BC: midpoint (9, 10), gradient −3/4edge: gradient 4/3, so 4x − 3y = 6
    48124812ABC2x + y = 18(9, 10)BC: midpoint (9, 10), gradient −3/4edge: gradient 4/3, so 4x − 3y = 6
    The edge between B and C passes through (9, 10) with gradient 43: 4x − 3y = 6.
  3. 3.(a) The edges are 2x + y = 18 and 4x − 3y = 6.

    48124812ABC2x + y = 184x − 3y = 62x + y = 184x − 3y = 6
    48124812ABC2x + y = 184x − 3y = 62x + y = 184x − 3y = 6
    (a) The two edges are 2x + y = 18 and 4x − 3y = 6.
  4. 4.Solve them together. Multiply the first equation by 3: 6x + 3y = 54. Add the second: 10x = 60, so x = 6, and y = 18 − 12 = 6. The edges meet at (6, 6).

    48124812ABC2x + y = 184x − 3y = 6(6, 6)6x + 3y = 54, add 4x − 3y = 6: 10x = 60x = 6, y = 6
    48124812ABC2x + y = 184x − 3y = 6(6, 6)6x + 3y = 54, add 4x − 3y = 6: 10x = 60x = 6, y = 6
    Solved together, they meet at (6, 6).
  5. 5.The distance from (6, 6) to A is √52 + 52 = √50, to B is √72 + 12 = √50, and to C is √12 + 72 = √50.

    48124812ABC2x + y = 184x − 3y = 6(6, 6)A: 5² + 5² = 50, B: 7² + 1² = 50, C: 1² + 7² = 50
    48124812ABC2x + y = 184x − 3y = 6(6, 6)A: 5² + 5² = 50, B: 7² + 1² = 50, C: 1² + 7² = 50
    The point (6, 6) is √50 from each station.
  6. 6.(b) The edges meet at (6, 6), which is √50 = 5√2 ≈ 7.07 km from each station. Check on the third edge, between A and C: its midpoint is (3, 7) and its gradient is −13, which gives x + 3y = 24, and 6 + 3 × 6 = 24.

    48124812ABC(6, 6)(6, 6) is √50 ≈ 7.07 km from eachcheck on AC's bisector: 6 + 3 × 6 = 24
    48124812ABC(6, 6)(6, 6) is √50 ≈ 7.07 km from eachcheck on AC's bisector: 6 + 3 × 6 = 24
    (b) (6, 6), 5√2 ≈ 7.07 km from each station; the third edge, x + 3y = 24, passes through it too.

Answer: (a) 2x + y = 18 and 4x − 3y = 6. (b) (6, 6), 5√2 ≈ 7.07 km from each station

Common mistakes

  • Writing the edge through the midpoint with the gradient of AB, y − 4 = 12(x − 7). That line is parallel to AB; the edge crosses AB at a right angle, so its gradient is −2.
  • Leaving the edge as y − 10 = 43(x − 9) when whole numbers are asked for. Multiplying both sides by 3 clears the fraction and gives 4x − 3y = 6.

More voronoi diagrams problems, worked step by step →

Practice The Equation of a Voronoi Edge in the app