Coordinate Geometry Explorer

Two points determine a segment and an entire line. Drag either one to connect the right triangle, exact distance, midpoint, direction vector, inclination, line equations and perpendicular bisector.

Loading interactive simulation...

The distance formula is Pythagoras with the triangle rubbed out 🖖

The formula is usually taught as something to memorise, and it is not: drop a horizontal line from one point and a vertical line from the other, and they meet at a right angle. The legs are Δx and Δy, the segment is the hypotenuse, and d² = Δx² + Δy² is a² + b² = c² with the triangle left undrawn. This tool draws it. Try the 3-4-5 preset — legs of 3 and 4, distance exactly 5 — and it is the same triangle that has been on every school worksheet since Euclid.

A vertical segment has a length and no gradient 🖖

Put both points on x = 3 and the tool reports a distance of 10 and a gradient of undefined. Both are correct, and the pair of them is the point. The segment is plainly there and plainly 10 units long, so "undefined" cannot be saying the line is missing or strange — it is saying that Δy ÷ Δx divides by zero, and the failure belongs to the formula rather than to the line. A vertical line still has an equation, x = 3; it simply is not of the form y = mx + c, because that form assumes every x has exactly one y.

The midpoint is exact where the distance is not 🖖

The midpoint is an average: add the two x values, halve them, do the same for y. It is arithmetic, and it lands on a number you can write down exactly. The distance needs a square root, and square roots of sums of squares are almost never rational. The unit diagonal shows both at once — the midpoint is exactly (0.5, 0.5) while the distance is 1.41 and continues forever. Same two points, one answer exact and one approximated, and the difference is entirely in which operation you had to reach for.

The perpendicular bisector is an equation for fairness 🖖

Switch on the perpendicular bisector. Every point P on the green line satisfies PA = PB. Square both distances and expand: the x² and y² terms cancel, so a condition that looked quadratic becomes a straight line. For the 3-4-5 preset it is 6x + 8y = 39: one equation describing infinitely many equidistant points.

Problems solved in full

  1. The distance from the origin to the line 4x − 3y = 1 7 steps

    The tool prints the line through A and B as 4x − 3y = 1, and the segment as exactly 5. Ask it how far that line passes from a point that is not on it — the origin, say — and it has nothing to say. Derive that distance from the two points alone.

    1. Everything below comes out of one subtraction. B − A is the trip from A to B: three across, four up, which is exactly what the two leg rows report.

    2. Those legs are the sides of a right triangle whose hypotenuse is the segment, so its length is Pythagoras and nothing more. This is the pair where the root closes — 25 is a square, so the exact row prints 5 rather than a surd.

    3. The equation needs no division at all. Every point on the line makes the same gradient with A, and clearing that fraction turns it into Δy·x − Δx·y, equal to whatever that combination comes to at A. It is the form on the page, and it is the form that survives a vertical segment, where y = mx + c cannot be written down.

    4. Now read the coefficients you just produced. (4, −3) is (Δy, −Δx): the segment turned through a right angle. Rotating a vector does not change its length, so the normal is 5 long — the same 5 as AB. That is not an accident of this preset; it holds for every pair of points, and it is what makes the next line cheap.

    5. Move one unit along the normal and the left-hand side changes by 5, which is the normal's own length, so the value it takes at any point is the distance to the line multiplied by 5. Feed the origin in: the numerator collapses to 1, the denominator is that same 5, and the line misses the origin by exactly one fifth.

    6. Walk that fifth and you should land on the line itself. The foot of the perpendicular sits at (0.16, −0.12), and putting it back into 4x − 3y returns 0.64 + 0.36 = 1 — on the line, and 0.2 from where you started.

    7. One consequence comes free. If the denominator of the distance formula is |AB|, then |AB| times that distance is twice the area of the triangle with O, A and B at its corners.

    Answer

    The line passes 0.2 from the origin, and the triangle OAB has area exactly ½. Check the area by a route that never mentions distance: the shoelace formula gives ½|xAyB − xByA| = ½|5 − 4| = ½. Two derivations sharing nothing after the first subtraction, landing on the same number. The tool follows you as far as the third line and then goes quiet — the distance from a point, the foot of the perpendicular and the area are all things it does not compute.

  2. What the two leg readouts know about the grid 6 steps

    The panel gives Δx = 10.0 and Δy = −10.0. Work out how many grid points this segment passes through on its way, and decide whether the two legs alone were enough to tell you.

    1. Length first, because it gets divided later. √(10² + 10²) = √200 = 10√2, which the panel prints twice over: 14.14 rounded and 10√2 exact.

    2. Write the segment as a walk. X(t) = A + t(Δx, Δy) = (−5 + 10t, 6 − 10t), with t running from 0 to 1.

    3. X(t) has whole-number coordinates when tΔx and tΔy are both whole, and that happens exactly when t is a multiple of 1/g, where g is the highest common factor of |Δx| and |Δy|. Here g = gcd(10, 10) = 10, so t runs through tenths.

    4. Each tenth advances by (Δx/g, Δy/g) = (1, −1), giving nine points strictly between the ends: (−4, 5), (−3, 4), and so on down to (4, −3). They are evenly spaced, √2 apart, because the length divides by g as well.

    5. The same split says when the length comes out whole. |AB| = g√((Δx/g)² + (Δy/g)²), so the surd lives entirely in the reduced pair. Here that pair is (1, 1) and nothing can clear the √2. On the 3-4-5 preset g = 1 and the reduced pair is (3, 4), one leg pair of a Pythagorean triple, which is why that distance prints as exactly 5.

    6. The midpoint needs no separate work. It is the point at t = ½, so it lands on the grid exactly when ½ is a multiple of 1/g, that is when g is even. Here g = 10 and the midpoint (0, 1) is the fifth of the nine. On the 3-4-5 preset g = 1, and (2.5, 3) sits between grid lines.

    Answer

    Nine, and yes. The highest common factor of the two legs decides all of it, and both legs are on the panel: a segment between grid points crosses g − 1 others, its length is rational only when the reduced pair is a Pythagorean one, and its midpoint is a grid point only when g is even. That last test has a consequence worth carrying away. A grid point falls into one of four classes by the parity of its two coordinates, so among any five of them two must share a class, and the midpoint of those two lands on the grid.

Learning path

The triangle rules, and where they come from

References (2)
  • the origin of describing a curve by the coordinates of its points Descartes, R. (1637). La Géométrie, appendix to Discours de la méthode. Leiden: Jan Maire.
  • the theorem the distance formula is an application of Euclid. Elements, Book I, Proposition 47.

Example problems

  • 3-4-5 - Legs of 3 and 4 give a distance of exactly 5 — Pythagoras, in coordinates.
  • Horizontal - A horizontal pair: the gradient is 0 and the distance is just the run, 10.
  • Vertical - 10 units long with no gradient at all — undefined is a fact about the formula, not the line.
  • Negative gradient - Down exactly as fast as it goes along: gradient -1, distance 14.14.
  • Unit diagonal - The midpoint is exactly (0.5, 0.5) while the distance, 1.41, never terminates.