Distance Calculator

Choose where your two points are: on a graph, in three-dimensional space, or on the Earth. Type the coordinates and the distance appears with every step of the working. For points on a graph you also get the midpoint and a drawing; for places on the Earth you get kilometres, miles and the direction.

How it is calculated

Choose graph, space or Earth.

Type the coordinates of the first point.

Type the coordinates of the second point.

Read the distance and follow the steps.

Formula

2D: d = √((x₂ − x₁)² + (y₂ − y₁)²)

3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

Midpoint: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)

On the Earth: d = radius × angle between the two places (in radians)

What is the Distance Calculator?

A distance calculator tells you how far apart two points are. If the points are on a graph, it applies the distance formula from coordinate geometry. If they are in three-dimensional space, it uses the same formula with one more term. If they are two places on the Earth, it works out the shortest path over the curved surface from their latitude and longitude.

For graph points the page also shows the midpoint and a drawing with the horizontal and vertical gaps marked, so the link with the Pythagoras theorem is easy to see. For places on the Earth the answer comes in kilometres, miles and nautical miles, along with the compass direction in which you would set out. A table of air distances between large Indian cities is given for quick reference.

How to calculate it by hand

1. Write down the coordinates of both points.

2. Subtract the first x from the second x. Do the same for y, and for z if there is one.

3. Square each of these differences.

4. Add the squares together.

5. Take the square root of the total. That is the distance.

6. For the midpoint, take the average of the two x values and the average of the two y values.

The distance formula is Pythagoras in disguise

Join two points on a graph and draw one horizontal and one vertical line from them so that a right-angled triangle is formed. The horizontal side is the difference in x and the vertical side is the difference in y. The line joining the points is the hypotenuse. The Pythagoras theorem then gives its length as the square root of the two squares added together. Nothing more than this is hidden in the formula.

Adding a third direction

In space a point needs three numbers: how far along, how far across and how far up. The distance formula simply grows by one term. You can think of it as using Pythagoras twice: once on the floor to get the diagonal across, and once more with the height to get the slanting line through the air. The diagonal of a room from one floor corner to the opposite ceiling corner is found in exactly this way.

Distance on a round Earth

A flat formula fails for places far apart because the ground curves. Instead we find the angle between the two places as seen from the centre of the Earth, using what is called the haversine formula, and multiply that angle by the Earth's radius of about 6371 km. Since the Earth bulges a little at the equator, a small correction is applied to bring the answer within a few metres over thousands of kilometres.

Worked example, step by step

In a Class 10 coordinate geometry sum, Farhan has to find how far the point (2, 3) is from the point (10, 9).

Subtract the coordinates of the first point from the second: x: 10 − 2 = 8 y: 9 − 3 = 6

Square each difference and add: 8² + 6² = 64 + 36 = 100

Take the square root: Distance = √100 = 10

Answer: Distance 10; Midpoint (6, 6); Change in x 8

Common mistakes to avoid

Subtracting x from y instead of x from x and y from y.

Forgetting to square a negative difference properly. The square is always positive.

Adding the differences first and squaring afterwards.

Entering longitude in the latitude box, or leaving out the minus sign for west and south.

Expecting the air distance to match the road distance shown by a map app.

Where it is used

Coordinate geometry problems in Class 9 and 10.

Finding the length of a diagonal in a room or a box.

Estimating flight distance between two cities.

Checking how far a delivery point is from a shop as the crow flies.

Game and graphics programming, where distance between objects is needed.

Frequently asked questions

Does it matter which point I enter first?

No. The differences are squared, so the sign disappears and the distance is the same either way.

How do I get the latitude and longitude of a place?

Open any map app, press and hold on the place, and the two numbers are shown. Enter them in decimal degrees, for example 17.3850 and 78.4867 for Hyderabad.

My coordinates are in degrees, minutes and seconds. What should I do?

Type them as they are with spaces, for example 28 36 50 N. The calculator changes them to decimal degrees for you: degrees + minutes ÷ 60 + seconds ÷ 3600, which gives 28.6139.

Why is the road distance more than the answer here?

This is the straight air distance. Roads and railway lines cannot go straight, so they are usually 15 to 40 per cent longer.

What is a great circle?

It is the largest circle that can be drawn on a sphere, like the equator. The shortest route between two places on the Earth always lies along a great circle, which is why long flights look curved on a flat map.