Coordinate Geometry Calculator
Enter two points to instantly find the distance, midpoint, and slope. Switch to Section Formula mode to find the point that divides a line segment in any given ratio — internally or externally.
Calculating...
Enter two points and click Calculate to find the distance, midpoint, and more.
How the Coordinate Geometry Formulas Connect
All three formulas operate on the same two points A and B — the difference is what property of the segment they reveal.
Distance Formula
The straight-line length between A and B. Derives from the Pythagorean theorem on Δx and Δy.
Midpoint Formula
The point exactly halfway between A and B. Special case of the section formula with m:n = 1:1.
Section Formula (Internal)
Point P divides AB in ratio m:n, lying between A and B. When m=n=1, P equals the midpoint.
Section Formula (External)
Point P divides AB externally — lies outside the segment, on the extension beyond A or B. Requires m ≠ n.
Distance vs Midpoint vs Section Formula
They all start with the same two points. The choice depends on what question you're answering.
Distance Formula
"How far apart are A and B?"
- → Navigation and map distances
- → Engineering tolerances
- → Collision detection in games
- → Checking if a point is within range
Midpoint Formula
"What is the centre of AB?"
- → Bisecting a segment
- → Finding the centre of a bounding box
- → Averaging two positions
- → Construction geometry (perpendicular bisector)
Section Formula
"Where does ratio m:n fall on AB?"
- → Architectural proportioning
- → Linear interpolation (lerp)
- → Dividing a route by time ratio
- → External: extrapolating beyond a segment
How to Find the Distance Between Two Points
The distance formula is a direct application of the Pythagorean theorem. Given points A(x₁, y₁) and B(x₂, y₂), the horizontal separation is Δx = x₂ − x₁ and the vertical separation is Δy = y₂ − y₁. These form the legs of a right triangle with AB as the hypotenuse:
d = √(Δx² + Δy²)
For example, the distance from (0, 0) to (3, 4) is √(9 + 16) = √25 = 5. This is the classic 3-4-5 right triangle. The distance formula works for any two points in the coordinate plane, including points with negative coordinates or decimal coordinates.
How to Find the Midpoint of a Line Segment
The midpoint of a segment is the point exactly halfway between the two endpoints. Because coordinates are independent in the x and y directions, the midpoint is simply the average of each coordinate separately:
M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2)
The midpoint formula is a special case of the section formula where the ratio is 1:1 — the point divides the segment into two equal parts. If you need to find the perpendicular bisector of a segment (a common geometry construction), the midpoint is the starting point, and the slope of the bisector is the negative reciprocal of the segment's slope.
How to Use the Section Formula
The section formula finds the coordinates of a point P that divides a segment AB in a given ratio m:n. There are two cases:
Internal division (P is between A and B): P = ((mx₂ + nx₁) / (m + n), (my₂ + ny₁) / (m + n)). For example, if m = 2 and n = 1, the point is two-thirds of the way from A to B.
External division (P is outside AB, on the extension): P = ((mx₂ − nx₁) / (m − n), (my₂ − ny₁) / (m − n)). External division requires m ≠ n; when m = n the formula is undefined because the denominator is zero. The external point lies beyond B (when m > n) or beyond A (when n > m).
In programming, internal division is equivalent to linear interpolation (lerp): lerp(A, B, t) = A + t(B − A), where t = m / (m + n). The section formula with ratio 1:1 always gives the midpoint, regardless of which points you use.
Coordinate Geometry FAQ
What is the distance formula between two points?
d = √((x₂−x₁)² + (y₂−y₁)²). This formula computes the straight-line (Euclidean) distance using the Pythagorean theorem. Δx = x₂−x₁ is the horizontal leg and Δy = y₂−y₁ is the vertical leg; the distance is the hypotenuse. Works for any pair of coordinates, including negatives and decimals.
How do I find the midpoint of a line segment?
M = ((x₁+x₂)/2, (y₁+y₂)/2). Average the x-coordinates for the midpoint's x, and average the y-coordinates for its y. The midpoint is the point that divides the segment into two equal halves — it's the section formula result when the ratio is 1:1.
What is the section formula in coordinate geometry?
The section formula finds a point P that divides segment AB in a given ratio m:n. For internal division (P between A and B): Px = (mx₂+nx₁)/(m+n), Py = (my₂+ny₁)/(m+n). For external division (P outside AB): Px = (mx₂−nx₁)/(m−n), Py = (my₂−ny₁)/(m−n). The ratio m:n tells you how much closer P is to B (m) vs A (n).
What is the difference between internal and external division?
Internal division: the dividing point P lies between A and B on the segment. External division: P lies outside the segment, on its extension. For internal 2:1 division, P is 2/3 of the way from A to B. For external 2:1 division, P is beyond B at a position such that AP:PB = 2:1 measured in opposite directions. External division is undefined when m=n because the denominator (m−n) equals zero.
What does slope tell you about a line?
Slope m = (y₂−y₁)/(x₂−x₁) = Δy/Δx measures the steepness and direction of a line. A positive slope means the line rises left-to-right. A negative slope means it falls. Slope 0 is horizontal. An undefined slope (denominator = 0) means a vertical line. The slope is the same regardless of which two points on the line you choose — it's a property of the line, not the points.
Can I use negative coordinates?
Yes — the distance, midpoint, and section formulas all work correctly with any real-number coordinates. Negative x values are to the left of the y-axis; negative y values are below the x-axis. For example, the distance from (−3, 1) to (5, −3) is √((5−(−3))² + (−3−1)²) = √(64+16) = √80 ≈ 8.944.
What if the two points are the same?
If A = B (both coordinates are identical), the distance is zero, and the midpoint is A itself. This is mathematically valid but usually indicates an input error since a line segment of zero length is degenerate. The calculator will flag same-point input with an error message to avoid confusion.
How does the midpoint formula relate to the section formula?
The midpoint is the special case where m = n = 1 in the section formula. Substituting: Px = (1×x₂ + 1×x₁)/(1+1) = (x₁+x₂)/2, Py = (1×y₂ + 1×y₁)/(1+1) = (y₁+y₂)/2 — exactly the midpoint formula. In general, any ratio m:n with m=n will produce the midpoint, not just 1:1.
Related Calculators
Pythagorean Theorem Calculator
Find the hypotenuse — the same theorem behind the distance formula.
Circle Calculator
Radius, diameter, circumference, area — uses the distance formula for the radius.
Surface Area Calculator
3D geometry — cube, sphere, cylinder, cone and pyramid surface areas.
Volume Calculator
Extend 2D geometry into 3D — volume of common shapes.
Quadratic Formula Calculator
Solve ax²+bx+c=0 — the intersections of parabolas with the x-axis.