Calculate distance between two points in 2D or 3D space with Euclidean distance, midpoint, squared distance, unit direction vector, slope, angle.
Last updated
Coordinate geometry
Calculate distance between two points in 2D or 3D space, then compare midpoint and path-style alternatives.
This distance calculator finds the straight-line Euclidean distance between two points, shows the midpoint, and adds squared distance plus axis-aligned comparisons so the result is more useful than a bare square-root output.
Distance between two points calculator Use this page as a distance formula calculator for 2D or 3D coordinates, with midpoint, squared distance, and path comparison outputs built in.
Mode
Use planar coordinates for distance between two points on a graph or worksheet.
Quick presets
Classic coordinate-geometry check
Point 1
Point 2
Straight-line distance
5
Distance between Point 1 and Point 2 in 2D Euclidean space.
Squared distance
25
Manhattan path
7
Chebyshev span
4
Distance to midpoint
2.5
Coordinate deltas
Δx = 3, Δy = 4
Midpoint
(1.5, 2)
Unit direction vector
<0.6, 0.8>
Slope and direction angle
Slope: 1.33; angle: 53.13° from the positive x-axis
Interpretation
This is the direct Euclidean shortcut across the plane. The axis-aligned path would be 7 units, while the longest single-axis change is 4 units.
The unit direction vector points from Point 1 toward Point 2 with length 1, so it is useful when the problem needs direction as well as distance.
Distance calculator for distance between two points in 2D or 3D space
Use this distance calculator to find the straight-line distance between two points in 2D or 3D space, then review squared distance, midpoint, and axis-by-axis comparisons. It is designed for coordinate geometry intent such as distance between two points, distance formula calculator, 2D distance calculator, and 3D distance calculator rather than map routing or driving directions.
What this distance calculator is actually measuring
This page measures Euclidean distance, which means the shortest straight-line segment between two coordinates. In coordinate geometry that is the core answer behind distance between two points, and it comes directly from the Pythagorean theorem.
That is different from a route, road, or travel distance. If you are measuring locations on the Earth's surface, switch to the coordinates distance calculator. This page is for ordinary x-y or x-y-z coordinate systems where straight-line geometry is the intended model.
Distance formula in 2D
For two points (x1, y1) and (x2, y2), first find the coordinate differences Δx = x2 - x1 and Δy = y2 - y1. Those differences form the legs of a right triangle, so the line segment joining the two points is the hypotenuse.
That gives the standard 2D distance formula. The squared distance is often worth checking first because it avoids the square root and still tells you whether one point pair is farther apart than another.
d^2 = (x2 - x1)^2 + (y2 - y1)^2
Squared distance in the coordinate plane.
d = sqrt((x2 - x1)^2 + (y2 - y1)^2)
Euclidean distance between two 2D points.
Distance formula in 3D
The 3D version extends the same idea by adding the z-axis. Once you know Δx, Δy, and Δz, you square each component, add them, and take the square root. That produces the Euclidean distance in space rather than only on a flat plane.
This is the version used for problems involving three-dimensional points, models, physics coordinates, and graphics-style geometry. It answers 3D distance calculator intent without forcing the user to jump to a separate page for the same formula family.
d^2 = (x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2
Squared distance in three-dimensional space.
d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
Euclidean distance between two 3D points.
Why midpoint still matters on a distance calculator
The midpoint is the exact halfway coordinate on the segment joining the two points. It is useful because it lets you check whether the geometry feels right after you compute the distance. If the midpoint looks wrong, the original inputs or signs are often wrong too.
The midpoint also explains why the result layer on this page shows distance to the midpoint. Once the midpoint is found, each endpoint is exactly half the total Euclidean distance away, which is a practical self-check for students and a quick sanity check for anyone debugging coordinates.
M = ((x1 + x2)/2, (y1 + y2)/2)
Midpoint formula in 2D. This is the specific relationship the calculator applies when building the result.
M = ((x1 + x2)/2, (y1 + y2)/2, (z1 + z2)/2)
Midpoint formula in 3D. This is the specific relationship the calculator applies when building the result.
Direction vector, unit vector, angle, and slope
Distance tells you how far apart the points are, but many coordinate geometry tasks also need the direction from Point 1 to Point 2. The direction vector is simply the coordinate difference vector: in 2D it is <Δx, Δy>, and in 3D it is <Δx, Δy, Δz>. It points from the first coordinate toward the second coordinate.
The unit direction vector divides that direction vector by the Euclidean distance so its length is exactly 1. That is useful in geometry, physics, graphics, and vector problems because it separates direction from magnitude. If the distance is zero, there is no unique unit direction because the two points coincide.
For 2D problems, the calculator also reports the slope and the direction angle from the positive x-axis. A vertical segment has no finite slope, so the page labels it as a vertical line rather than returning a misleading number. In 3D, there is not one single 2D slope or one planar angle that fully describes the direction, so the unit vector is the cleaner direction summary.
u = <Δx, Δy> / d
Unit direction vector in 2D, where d is the Euclidean distance.
θ = atan2(Δy, Δx)
2D direction angle measured from the positive x-axis.
Euclidean distance versus Manhattan distance
A strong competitor gap in this search space is that most pages stop at Euclidean distance only. That is mathematically correct, but not always the most interpretable result. Euclidean distance is the direct shortcut. Manhattan distance adds the absolute coordinate changes instead, which is what an axis-by-axis route would total if you could only move horizontally, vertically, and optionally along z.
The comparison is useful because it tells you how much longer a stepped path would be than the direct segment. For the classic 3-4-5 triangle, the Euclidean distance is 5 while the Manhattan path is 7. The difference is part of what makes the straight-line result meaningful.
Worked examples
In 2D, the points (0, 0) and (3, 4) give Δx = 3 and Δy = 4. Squaring and adding gives 9 + 16 = 25, so the distance is sqrt(25) = 5. The midpoint is (1.5, 2), the Manhattan path is 7, and the largest single-axis change is 4.
In 3D, the points (0, 0, 0) and (3, 4, 12) give squared distance 9 + 16 + 144 = 169, so the direct distance is 13. The midpoint is (1.5, 2, 6), and each endpoint sits 6.5 units from that midpoint.
When the zero-distance case is the right answer
If both points are identical, the distance is zero. That is not an error. It means the segment collapses to a single point, the midpoint equals that same point, and every comparison distance also drops to zero.
This case matters because many thin calculators treat it like a trivial output and move on. In practice, it is often the easiest way to confirm whether a worksheet, data set, or graphics transform duplicated a point by mistake.
What this page does not solve
This calculator is not a map route planner, a great-circle calculator, or a point-to-line distance tool. It also does not solve slope, line equations, or circle intersections. Those are neighboring intents, but not the same result.
If your problem is about latitude and longitude, use the coordinates distance calculator. If your problem is specifically about the midpoint only, use the midpoint calculator. If your problem starts from a right triangle rather than two points, the Pythagorean theorem calculator is often the better fit.
Find the coordinate differences, square them, add them, and take the square root. In 2D that is sqrt((x2 - x1)^2 + (y2 - y1)^2). In 3D you add the z term as well.
What is the distance between (0,0) and (3,4)?
The distance is 5. This is the classic 3-4-5 right triangle, so the squared distance is 25 and the Euclidean distance is sqrt(25) = 5.
What is the midpoint between two points?
The midpoint is the coordinate halfway between both points. In 2D it is ((x1 + x2)/2, (y1 + y2)/2), and in 3D it includes the z average as well.
What is squared distance and why would I use it?
Squared distance is the value inside the square root before you take the root itself. It is useful for comparisons because it preserves ordering without the extra square-root step.
What is the difference between Euclidean distance and Manhattan distance?
Euclidean distance is the direct straight-line shortcut between two points. Manhattan distance adds the absolute axis changes instead, which represents an axis-by-axis path rather than a direct segment.
Does the order of the points matter?
No. Swapping Point 1 and Point 2 changes the signs of the coordinate differences, but the squared terms and the final distance stay the same.
Can this page calculate distance from latitude and longitude?
Not correctly for Earth-surface intent. Latitude and longitude should be handled with a great-circle method, which is why Calcipedia has a separate coordinates distance calculator for that job.
What happens if both points are the same?
The distance is zero, the midpoint is that same point, and every comparison output also collapses to zero. It is a valid geometry result, not an error.
Is this the same as a distance formula calculator?
Yes for core geometry intent. This page covers the same distance-formula workflow for 2D and 3D points, while the synonym-focused distance-formula route is kept aligned with the same topic family.
What is a unit direction vector between two points?
The unit direction vector points from Point 1 toward Point 2 and has length 1. Calculate it by dividing each coordinate difference by the Euclidean distance. For example, the points (0,0) and (3,4) have direction vector <3,4>, distance 5, and unit direction vector <0.6,0.8>.
How do I find the direction angle between two 2D points?
Use atan2(Δy, Δx), then convert the result to degrees if needed. The calculator reports that angle from the positive x-axis for 2D points. For 3D points, use the unit direction vector instead because one flat angle cannot fully describe direction in space.