{
    "name": "Distance Calculator",
    "url": "https://calculators.geekmidst.com/calculators/distance-calculator",
    "markdown": "https://calculators.geekmidst.com/calculators/distance-calculator.md",
    "category": "Algebra, geometry & advanced math",
    "description": "Find the straight-line distance between two points from their coordinates in the plane or in space, plus the midpoint and slope.",
    "summary": "The distance between two points is the Pythagorean theorem applied to the differences in their coordinates.",
    "also_called": [
        "Distance formula calculator",
        "Two-point distance calculator"
    ],
    "applies_to": "Worldwide",
    "last_updated": "2026-10-29",
    "computation": "Results are computed in the visitor’s browser on the HTML page. This API describes the calculator; it does not compute results.",
    "inputs": [
        {
            "name": "dims",
            "label": "Space",
            "type": "segmented",
            "default": "2d",
            "options": {
                "2d": "2D (x, y)",
                "3d": "3D (x, y, z)"
            }
        },
        {
            "name": "x1",
            "label": "Point 1: x₁",
            "type": "number",
            "default": "1"
        },
        {
            "name": "y1",
            "label": "Point 1: y₁",
            "type": "number",
            "default": "2"
        },
        {
            "name": "z1",
            "label": "Point 1: z₁",
            "type": "number",
            "default": "0",
            "shown_when": {
                "dims": "3d"
            }
        },
        {
            "name": "x2",
            "label": "Point 2: x₂",
            "type": "number",
            "default": "4"
        },
        {
            "name": "y2",
            "label": "Point 2: y₂",
            "type": "number",
            "default": "6"
        },
        {
            "name": "z2",
            "label": "Point 2: z₂",
            "type": "number",
            "default": "0",
            "shown_when": {
                "dims": "3d"
            }
        }
    ],
    "outputs": [
        {
            "key": "distance",
            "label": "Distance",
            "format": "number"
        },
        {
            "key": "midpoint",
            "label": "Midpoint",
            "format": "text"
        },
        {
            "key": "slope",
            "label": "Slope (2D)",
            "format": "text"
        },
        {
            "key": "dx",
            "label": "Δx",
            "format": "number"
        },
        {
            "key": "dy",
            "label": "Δy",
            "format": "number"
        },
        {
            "key": "dz",
            "label": "Δz",
            "format": "number"
        },
        {
            "key": "squared",
            "label": "Distance squared",
            "format": "number"
        }
    ],
    "formula": {
        "text": "d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²);  midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2, …);  slope = Δy ÷ Δx",
        "variables": {
            "(x₁, y₁, z₁)": "the first point",
            "(x₂, y₂, z₂)": "the second point (z is 0 in 2D)"
        }
    },
    "worked_example": {
        "inputs": {
            "dims": "2d",
            "x1": "1",
            "y1": "2",
            "z1": "0",
            "x2": "4",
            "y2": "6",
            "z2": "0"
        },
        "steps": [
            "Δx = 4 − 1 = 3 and Δy = 6 − 2 = 4.",
            "d = √(3² + 4²) = √25 = 5.",
            "Midpoint = ((1 + 4)/2, (2 + 6)/2) = (2.5, 4)."
        ],
        "result": "The points (1, 2) and (4, 6) are 5 units apart, with midpoint (2.5, 4)."
    },
    "interpretation": "The answer is in the same units as the coordinates. For points given as latitude and longitude, this flat-plane formula is wrong over any real distance; use a great-circle (haversine) method instead.",
    "assumptions": [
        "Coordinates are Cartesian and use the same unit on every axis."
    ],
    "limitations": [
        "Not for latitude and longitude: the Earth is curved."
    ],
    "rules": null,
    "faqs": [
        {
            "question": "Is the distance formula the same as Pythagoras?",
            "answer": "Yes. Δx and Δy are the legs of a right triangle and the distance is its hypotenuse; in 3D the theorem is applied twice."
        },
        {
            "question": "Why is the slope undefined?",
            "answer": "When both points have the same x, the line is vertical and Δy ÷ Δx would divide by zero."
        }
    ],
    "sources": [],
    "related": [
        {
            "name": "Pythagorean Theorem Calculator",
            "url": "https://calculators.geekmidst.com/calculators/pythagorean-theorem-calculator"
        },
        {
            "name": "Right Triangle Calculator",
            "url": "https://calculators.geekmidst.com/calculators/right-triangle-calculator"
        },
        {
            "name": "Length Converter",
            "url": "https://calculators.geekmidst.com/calculators/length-converter"
        }
    ],
    "disclaimer": null,
    "publisher": "GM¹X CalcVerse"
}