Coordinate Calculator - Distance Between Points & Midpoint

    Two points on a plane define a line segment. Enter coordinates (x1, y1) and (x2, y2) to get the Euclidean distance, midpoint coordinates and the full formula shown step by step.

    Parameters

    Enter data for calculations

    x-coordinate of the first point

    y-coordinate of the first point

    x-coordinate of the second point

    y-coordinate of the second point

    Form progress0 / 4 fields

    💡 Fill in all required fields to unlock the calculate button

    Distance, midpoint, formula - one click

    Give the calculator four numbers - x and y for each of two points - and it returns three results at once: the straight-line distance between them, the exact midpoint of the segment they define, and the full formula with every substitution visible so you can follow the arithmetic.

    Quick start
    Enter A = (1, 2) and B = (4, 6). Click "Calculate". Distance: 5.0000. Midpoint: (2.50, 4.00). The formula shows sqrt((4-1)^2 + (6-2)^2) = sqrt(9 + 16) = sqrt(25) = 5.

    The distance formula explained

    The Euclidean distance between points A(x1, y1) and B(x2, y2) comes directly from the Pythagorean theorem. Draw a right triangle with the horizontal leg (x2 - x1) and the vertical leg (y2 - y1). The hypotenuse is the distance:

    d = sqrt( (x2 - x1)^2 + (y2 - y1)^2 )

    The midpoint S divides the segment AB into two equal halves. Its coordinates are the arithmetic means of the corresponding coordinates of A and B:

    S = ( (x1 + x2) / 2, (y1 + y2) / 2 )

    Reference table - common coordinate pairs

    Point A Point B Distance Midpoint
    (0, 0) (3, 4) 5.0000 (1.50, 2.00)
    (1, 2) (4, 6) 5.0000 (2.50, 4.00)
    (-3, -2) (5, 4) 10.0000 (1.00, 1.00)
    (0, 0) (1, 1) 1.4142 (0.50, 0.50)
    (2, 7) (10, 1) 10.0000 (6.00, 4.00)
    (0.5, 1.5) (3.5, 5.5) 5.0000 (2.00, 3.50)

    Practical examples

    Screen layout: A button sits at pixel (120, 80) and a label at (360, 200). Distance = sqrt((360-120)^2 + (200-80)^2) = sqrt(57600 + 14400) = sqrt(72000) = 268.33 px. The midpoint (240, 140) is where a connecting line would cross the center.
    UI/UX designers use this to check spacing
    GPS approximation: Two city centers have approximate planar coordinates (10.2, 52.4) and (10.8, 52.9). Distance = sqrt(0.36 + 0.25) = 0.7810 degrees. At mid-latitudes, 1 degree of latitude is about 111 km, so the straight-line distance is roughly 87 km.
    For short distances, planar approximation is adequate
    Game development: A player character is at (5, 3) and the enemy at (12, 8). Distance = sqrt(49 + 25) = 8.6023 units. If the attack range is 10 units, the enemy is within range.
    2D collision detection relies on this formula
    Surveying: Two boundary markers have local coordinates (100, 200) and (180, 260). Distance = sqrt(6400 + 3600) = 100.00 m. Midpoint = (140, 230) - that is where you would place a fence post splitting the boundary in half.
    Land surveyors convert GPS to local grids for this calculation
    Classroom problem: Find the distance between A(-2, 3) and B(4, -1). d = sqrt((4-(-2))^2 + (-1-3)^2) = sqrt(36 + 16) = sqrt(52) = 7.2111. Midpoint = (1.00, 1.00).
    Negative coordinates work exactly the same way
    Robotics: A robot arm tip moves from (0, 15) to (20, 0). Distance traveled = sqrt(400 + 225) = 25.00 cm. This determines the minimum cable length needed for the end effector.
    Joint-space vs Cartesian-space planning both use distance

    Midpoint - splitting a segment in half

    The midpoint formula averages each coordinate independently. This works because the midpoint is equidistant from both endpoints along each axis. You can verify: the distance from A to S always equals the distance from S to B.

    Property Formula Notes
    Distance AB d = sqrt((x2-x1)^2 + (y2-y1)^2) Always non-negative, zero only if A = B
    Midpoint S S = ((x1+x2)/2, (y1+y2)/2) Divides AB in ratio 1:1
    Slope of AB m = (y2-y1) / (x2-x1) Undefined when x1 = x2 (vertical line)
    Section point (ratio m:n) P = ((m*x2 + n*x1)/(m+n), (m*y2 + n*y1)/(m+n)) Midpoint is the special case m = n = 1

    FAQ - Frequently Asked Questions

    Does this work for 3D coordinates?
    This calculator handles 2D coordinates (x, y). For 3D, the formula extends to d = sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2) - same idea, one more term under the square root. The midpoint adds a z-component: Sz = (z1+z2)/2.
    Can I use this for GPS latitude/longitude?
    For short distances (under ~100 km), the Euclidean approximation gives reasonable results. For longer distances, the curvature of the Earth matters and you need the Haversine formula, which accounts for the spherical geometry. Also note that 1 degree of longitude shrinks as you move away from the equator.
    Why is the distance always positive?
    The formula squares each difference, so negative values become positive. Then the square root is non-negative by definition. Distance is a metric: it satisfies d(A,B) >= 0, with d(A,B) = 0 only when A and B are the same point. This property is called positive-definiteness.
    What is Euclidean vs Manhattan distance?
    Euclidean distance is the straight line (as the crow flies). Manhattan distance is the sum of absolute differences: |x2-x1| + |y2-y1| - like walking city blocks where you can only go horizontally or vertically. For A(1,2) and B(4,6): Euclidean = 5, Manhattan = 3 + 4 = 7.
    How is the distance formula derived from the Pythagorean theorem?
    Plot points A and B. Draw a horizontal line from A to the point C(x2, y1) - this creates a right triangle ABC. The horizontal leg AC has length |x2-x1|, the vertical leg CB has length |y2-y1|. By the Pythagorean theorem: AB^2 = AC^2 + CB^2 = (x2-x1)^2 + (y2-y1)^2. Take the square root of both sides.
    Can I find a point that divides a segment in a ratio other than 1:1?
    Yes. For a point P dividing AB in the ratio m:n, use: P = ((m*x2 + n*x1)/(m+n), (m*y2 + n*y1)/(m+n)). The midpoint is the case where m = n = 1. For example, to find the point 1/3 of the way from A to B, set m = 1, n = 2.

    Related tools

    Pythagorean Theorem Calculator

    The distance formula is the Pythagorean theorem applied to coordinate geometry - Open calculator

    Scale Calculator

    Convert coordinates measured on a scaled drawing to real-world dimensions - Open calculator

    Area Calculator

    Once you know the distances between vertices, calculate the area of any shape - Open calculator

    Powers & Roots Calculator

    The square root at the core of the distance formula - compute any root or power - Open calculator

    Absolute Value Calculator

    Distance along a single axis is the absolute value of the difference between coordinates - Open calculator

    Similar calculators from this section