Distance and Midpoint in Three Dimensions

Pythagoras twice, and one average per axis.

Two points as opposite corners of a box

Take two points in space, A(x₁, y₁, z₁) and B(x₂, y₂, z₂). Build the box whose edges run parallel to the three axes and which has A and B at opposite corners. Its edges are the gaps between the coordinates: Δx = x₂ − x₁ across, Δy = y₂ − y₁ along and Δz = z₂ − z₁ up. Δ is the Greek capital delta, read “change in”.

The vector from A to B is AB = (Δx, Δy, Δz), the end minus the start. The distance between the points, d, is its length: the long diagonal of the box.

ΔxΔzΔyfloord

A at one bottom corner and B at the opposite top corner. The floor diagonal, the upright edge Δz and the distance d make the shaded right triangle.

Pythagoras twice

First, across the floor of the box. The floor is a rectangle Δx by Δy, and its diagonal is the hypotenuse of a right triangle with those two legs: floor² = Δx² + Δy².

Second, up. The upright edge Δz is at right angles to the floor, so it is at right angles to every line in the floor, including the floor diagonal. The floor diagonal, the edge Δz and d make a right triangle with d as its hypotenuse: d² = floor² + Δz².

Put the first into the second: d² = Δx² + Δy² + Δz², so d = √(Δx² + Δy² + Δz²). The third square comes from the second right triangle, not from counting the dimensions.

A worked distance

Find the distance from A(1, 2, 3) to B(7, 10, 27). The gaps are 7 − 1 = 6, 10 − 2 = 8 and 27 − 3 = 24.

Across the floor, √(6² + 8²) = √(36 + 64) = √100 = 10. Then up, √(10² + 24²) = √(100 + 576) = √676 = 26. In one line, d = √(36 + 64 + 576) = √676 = 26.

The order of the points does not matter. From B to A the gaps are −6, −8 and −24, and the squares are the same: (−6)² = 36.

A negative gap, and a gap of zero

For P(2, −1, 4) and Q(−1, 3, 4), the gaps are −1 − 2 = −3, 3 − (−1) = 4 and 4 − 4 = 0. So PQ = √(9 + 16 + 0) = √25 = 5.

The gap in z is 0, because both points are at the same height. The box is then flat, and the distance is the two-dimensional one across the floor.

The midpoint: one average per axis

The midpoint M of AB has position vector (1/2)(a + b), half the sum of the position vectors of the ends. Taken one component at a time, that is the mean of the two coordinates on each axis, z included.

For A(1, 2, 3) and B(7, 10, 27): (1 + 7)/2 = 4, (2 + 10)/2 = 6 and (3 + 27)/2 = 15, so M = (4, 6, 15).

Checking the midpoint

From A(1, 2, 3) to M(4, 6, 15) the gaps are 3, 4 and 12, so AM = √(9 + 16 + 144) = √169 = 13. From M to B(7, 10, 27) the gaps are 7 − 4 = 3, 10 − 6 = 4 and 27 − 15 = 12, the same three, so MB = 13 as well.

The two halves are equal and add to 13 + 13 = 26, the whole distance, so M is halfway along AB. Each gap from A to M is half of the gap from A to B, which is why every length halves too.

√(x² + y²) = 5x = 3y = 4z = 6|v| = √(5² + 6²)= √(3² + 4² + 6²) = 7.81

the floor diagonal is √(x² + y²) = 5; stand z = 6 on its end and Pythagoras again gives |v| = √(5² + 6²) = 7.81, which is √(x² + y² + z²)

Make the box 3 by 4 by 12 and read the diagonal

A box 3 by 4 by 6: the floor diagonal is √(3² + 4²) = 5, and the space diagonal is √(5² + 6²) = √61, which is 7.81 to 2 decimal places. Drag the upright edge to 12, the gaps from A to the midpoint, and the space diagonal is √(25 + 144) = 13, half of 26.

An end from the midpoint

Turned around, the midpoint gives a missing end. Each coordinate of M is the mean of the two ends, so each coordinate of B is twice M’s, minus A’s. With A(1, 2, 3) and M(4, 6, 15), B = (2 × 4 − 1, 2 × 6 − 2, 2 × 15 − 3) = (7, 10, 27).

The usual mistakes

Adding the gaps. 6 + 8 + 24 = 38 is the walk along three edges of the box; squaring each gap first gives the straight line, 26.

Stopping on the floor. √(36 + 64) = 10 is the floor diagonal; the climb of 24 still has to go in.

Giving the gaps or the sums as the midpoint. (6, 8, 24) measures the movement from A to B, and (8, 12, 30) has not yet been halved; the midpoint is (4, 6, 15).

Halving twice. The midpoint is 26 ÷ 2 = 13 from A; 6.5 is a quarter of the way along.

A cable across a warehouse

In the application below, the cable runs from a corner on the floor to the opposite top corner of the room, so its length is the long diagonal of the room. The hook holding it halfway is at the mean of each coordinate, and the distance from a sensor to the hook is one more distance in three dimensions, with a gap that is not a whole number.

Worked example: A Cable Across a Warehouse from a Floor Corner to the Far Top Corner

Question A warehouse is a cuboid 12 m long, 4 m wide and 3 m high. With axes along its edges from the corner O on the floor, a cable runs straight from O to a light L at (12, 4, 3) in the opposite top corner. A sensor S is at (0, 4, 3). (a) Find the length of the cable. (b) A hook holds the cable at its midpoint M. Find the coordinates of M and the distance from the sensor to the hook.

  1. 1.The cable is the vector OL = 1243: along the length, across the width, and up the height of the room.

    12 m4 m3 mOLSOL =1243along the length, across the width, up the height
    12 m4 m3 mOLSOL =1243along the length, across the width, up the height
    The cable is the vector OL = 1243: along the length, across the width and up the height of the room.
  2. 2.(a) In three dimensions the length is √122 + 42 + 32 = √144 + 16 + 9 = √169 = 13 m.

    12 m4 m3 m13 mOLS122+ 42+ 32= 144 + 16 + 9 = 169OL =√169 = 13 m
    12 m4 m3 m13 mOLS122+ 42+ 32= 144 + 16 + 9 = 169OL =√169 = 13 m
    (a) Its length is √122 + 42 + 32 = √169 = 13 m.
  3. 3.The midpoint has the mean of each coordinate: M = (0 + 122, 0 + 42, 0 + 32) = (6, 2, 1.5).

    12 m4 m3 mM13 mOLSM = (12/2, 4/2, 3/2)M = (6, 2, 1.5)
    12 m4 m3 mM13 mOLSM = (12/2, 4/2, 3/2)M = (6, 2, 1.5)
    The midpoint has the mean of each coordinate: M = (6, 2, 1.5), halfway up the room.
  4. 4.From the sensor to the hook: SM = 6 − 02 − 41.5 − 3 = 6−2−1.5.

    12 m4 m3 mM13 mOLSSM =6 − 02 − 41.5 − 3=6−2−1.5
    12 m4 m3 mM13 mOLSSM =6 − 02 − 41.5 − 3=6−2−1.5
    From the sensor to the hook: SM = 6−2−1.5.
  5. 5.(b) M is at (6, 2, 1.5), and SM = √62 + 22 + 1.52 = √36 + 4 + 2.25 = √42.25 = 6.5 m. Check: 6.52 = 42.25.

    12 m4 m3 mM13 mOLS, 6.5 m from M36 + 4 + 2.25 = 42.25SM =√42.25= 6.5 m
    12 m4 m3 mM13 mOLS, 6.5 m from M36 + 4 + 2.25 = 42.25SM =√42.25= 6.5 m
    (b) SM = √36 + 4 + 2.25 = √42.25 = 6.5 m.

Answer: (a) 13 m; (b) M(6, 2, 1.5), and 6.5 m from the sensor

Common mistakes

  • Using only the floor: √122 + 42 = √160 ≈ 12.6 m. That is the diagonal of the floor; the cable also climbs 3 m, so the height enters the sum as a third square.
  • Putting the hook at a height of 3 m because the light is at the ceiling. The cable starts on the floor, so halfway along it is halfway up, at 1.5 m.

More vectors in the plane problems, worked step by step →

Practice Distance and Midpoint in Three Dimensions in the app