Coordinate differences turn two locations into one segment
For points (x₁, y₁) and (x₂, y₂), subtract matching coordinates to obtain Δx = x₂ − x₁ and Δy = y₂ − y₁. Those signed changes describe direction, while squaring removes their signs for length. The square root of Δx² + Δy² is the hypotenuse of the right triangle formed by the horizontal and vertical changes. Reversing the point order changes both delta signs but not the final distance.
A third coordinate adds one perpendicular component: distance becomes the square root of Δx² + Δy² + Δz². This is appropriate only when all axes belong to the same Cartesian frame and use compatible units. If the entries are latitude and longitude, the city distance calculator applies a spherical Earth model instead; degrees of latitude and longitude are not ordinary x and y lengths.
Prepare the coordinate frame before doing any arithmetic
- Identify the origin and axis directions
A drawing may put positive y upward, a screen may put it downward, and a survey grid may use easting and northing. Document the convention so the signed deltas can be interpreted after the length is found.
- Normalize every coordinate unit
Do not combine x in metres with y in centimetres or z in feet. Convert the coordinates first, then subtract. A unitless graph is acceptable only when every axis is genuinely on the same abstract scale.
- Select two-dimensional or three-dimensional mode
Leaving out z asserts that height or depth is irrelevant, not that it happens to be zero. Use 3D when the vertical component is part of the requested straight-line separation.
Three reproducible examples check the important cases
For a familiar planar check, take A = (0, 0) and B = (3, 4) in the same unit. The coordinate changes are 3 and 4, so d = √(3² + 4²) = √25 = 5. This 3-4-5 result confirms that the calculator uses the diagonal segment rather than adding the two changes to report 7.
Suppose a model records A = (2, −1, 4) metres and B = (8, 3, 1) metres. The changes from A to B are 6, 4, and −3 metres. Squared contributions are 36, 16, and 9 square metres, giving a sum of 61 square metres and the exact mathematical distance √61 metres. A decimal display may show about 7.81 or additional digits; it is not fixed to two places. Keep √61 when the model coordinates are exact, or round a measured result only to the precision justified by those measurements.
The deltas remain useful even though the output is unsigned: they say that B lies six metres in positive x, four in positive y, and three in negative z from A. When the task is to rescale one of those axes for a display, use the numeric mapping calculator rather than changing the geometry formula itself.
A boundary check uses coincident points. If P = (4, −2) and Q = (4, −2), both coordinate changes are zero and d = √(0² + 0²) = 0. Zero is therefore a valid distance, not a missing result or an error. Reversing any pair of points also leaves the distance unchanged because the changed delta signs disappear when squared.
Know what a Euclidean answer leaves out
- The segment passes directly between the points. It does not bend around walls, follow corridors, trace a trail, or respect a transportation network.
- A projected map grid can introduce scale distortion. For engineering or surveying decisions, use the coordinate reference system's prescribed geodetic method rather than treating any displayed x and y values as exact ground distance.
- Measurement uncertainty in each coordinate propagates into the result. A short displayed distance derived from coarse coordinates should not be reported with many confident decimals.
- Trip fuel and reimbursement require actual travelled distance. Once that value is known, the refill mileage calculator or a dedicated expense record is a better next step.
Match the distance definition to the decision
Use Euclidean coordinates
Choose this page for a chord in a common 2D or 3D Cartesian frame: a diagram, machine coordinate system, game space, or local mathematical model.
Use a geographic separation model
Choose a latitude-and-longitude method for approximate surface separation between cities. Declare the Earth model and do not label the answer as a driving route.
Use a routing or measurement service
Choose a network-aware service when roads, restrictions, terrain, real paths, traffic, or turn-by-turn instructions affect the distance. The formula here intentionally has none of that data.