# Distance Formula & Calculator

- What is distance?
- The distance formula for Euclidean distance
- Distance from a straight line or any continuous structure
- How to find the distance from one point to another using our distance calculator
- Driving distance between cities: a real-world example (to be checked and expanded)
- Distance from Earth to Moon and Sun, and astronomical distances
- Distance beyond length

Have you ever wanted to calculate the distance from one point to another or the distance between cities? Have you ever wondered what the distance definition is? We have all these answers and more, including a detailed explanation on how to calculate the distance between any two objects in 2D space. As a bonus point, we have a fascinating twist on how we perceive an talk about distance; we're sure you'll love it!

## What is distance?

Before we get to how to calculate distances, we should probably **clarify what distance is**. In the most typical meaning of distance, it is the 1D space between two objects. This definition is one way to say what almost all of us think of distance intuitively, but it is **not the only way we could talk about distance**. You will see in the following sections how the concept of distance can be extended beyond length. In fact, in more than one sense, that is the breakthrough behind Einstein's theory of relativity.

If we stick with the geometrical definition of distance we still **have to precise what kind of space we are working on**. In most cases, you are probably talking about 3 dimensions or less, since that's all we can imagine without our brains exploding. For this calculator, we will focus only on the 2D distance (with the 1D included as a special case). If you are **looking for the 3D distance between 2 points** we invite you to use our 3D distance calculator made specifically for that purpose.

To find the distance between two points, the first thing you need are two points, **obviously**. These points are described in mathematics by their coordinates in space. For each point in 2D space, we need 2 coordinates. These two coordinates are unique to this point. If you wish to find the **distance between two points in 1D space you can still use this calculator by simply setting one of the coordinates to be the same for both points**. Since this is a very special case, from now on we will talk about distance meaning "*2D distance*".

Next step to do, if you want **to be mathematical accurate and precise**, is to define the type of space you're working on. No, wait, don't run away! It is easier than you think. If you don't know what space you're working on or if you didn't even know there was more than one type of space, **you're most likely working in Euclidean space**. Since this is the "default" space in which we do almost every geometrical operations, it is the one we have set for the calculator to operate on. Let's **dive a bit deeper into Euclidean spaces**, what they are, what properties they have and why are so important.

## The distance formula for Euclidean distance

The Euclidean space or **Euclidean geometry is precisely what we all think of space of geometry** before we receive any deep mathematical training in any of these aspects. In Euclidean space the sum of triangle angles is 180º. Squares have all their angles equal to 90º, always... Which is something we all take for granted, but that is **not true in all spaces**. Let's also not confuse Euclidean space with multidimensional spaces. Euclidean space can have as **many dimensions as you want (as long as it's a finite number of them) and still be Euclidean**.

We do **not want to bore you with mathematical definitions** of what a "*space*" is and what makes the Euclidean space unique since that would be too complicated to explain in a simple distance calculator. However, we can try to give some examples of other spaces that are commonly used and that might help you understand why Euclidean space is not the only space. Also, you will **hopefully understand why we are not going to bother calculating distances in other spaces**.

The first example we present to you in a bit obscure, but I **hope you can excuse myself as a physicist** for starting with this very important type of space: "*Minkowski space*". The reason I've selected this is because it is **highly used in physics**, in particular in relativity theory, general relativity and even in relativistic quantum field theory. This space is very similar to Euclidean space, but differs from it in a very critical feature: dot product also called the *inner product* (not to be confused with the cross product).

Both the Euclidean and Minkowski space that we have talked about are what **mathematicians call flat space**. This means that space itself has flat properties; for example, the **shortest distance between any two points is always a straight line** between them (check the linear interpolation calculator). There are, however, other types of mathematical spaces called "*Curved spaces*" in which space is intrinsically curved and the shortest distance between two points is no a straight line.

This curved space is hard to imagine in 3D but for 2D we can imagine that instead of having a flat plane area we have a 2D space curved in the shape of, for example, the surface of a sphere. In this case, **very strange things happen**. For example, the shortest distance from one point to another is not a straight line, because any line in this space is curved due to the intrinsic curvature of the space. Another very strange feature of this space is that some parallel lines do **actually meet at some point**. You can understand this better by think of the so-called "parallels" that divide the earth into many time zones and cross each other at the poles.

It is important to note that **this is conceptually VERY different from a change of coordinates**. When we take the standard `x, y, z`

coordinates and convert into polar coordinates, or cylindrical coordinates, or even spherical coordinates but we will still be in Euclidean space. When we talk about **curved space we are talking about a very different space in terms of its intrinsic properties**. In spherical coordinates, you can still have a straight line and distance is measured in a straight line, even if that would be very hard to express in numbers.

Coming back to the Euclidean space we can now present you with **distance formula that we promised at the beginning**. The distance formula is `√(x₂ - x₁)² + (y₂ - y₁)²`

, which relates to the Pythagorean theorem, which is `a² + b² = c²`

, where `a`

and `b`

are legs of a right triangle and `c`

is the hypotenuse. Suppose (x₁,y₁) and (x₂,y₂)are **coordinates of the endpoints of the hypotenuse**. Then `(x₂ - x₁)²`

in the distance equation corresponds to `a²`

and `(y₂ - y₁)²`

corresponds to `b²`

. Since `c = √a² + b²`

, you can see how it is just an **extension of the Pythagorean theorem**.

## Distance from a straight line or any continuous structure

The distance formula we have just seen is the **standard Euclidean distance formula**, but if you think about it, it can seem a bit limited. Not always we would want to find the distance between two points, sometimes we want to calculate the **distance from a point to a line**, or to a circle... In this case, we first need to define what point in this line or circumference we will use for the calculation, and then use the distance formula that we have seen just above.

Here is when the concept of <portal cid=perpendicular line becomes of crucial importance. The distance between a point and a continuous object is defined via perpendicularity. From a geometrical point of view, the steps to be taken to measure the distance from one point to another are to **create a straight line between both points and then measure the length of that segment**. When we measure the distance from a point to a line, the question becomes "Which of the many possible lines should I draw?" in this case the answer is: **the one line that includes the point and is perpendicular to the first line** from which we want to measure the distance to the point. In the case that the point would be part of the line, the distance would be zero. For these 1D cases, one can only consider the distance between points, **since the line represents the whole 1D space**.

This **imposes restrictions on how to compute distances** results in some interesting geometrical properties. For example, we could redefine the concept of height of a triangle to be simply the distance from one vertex to the opposing side of the triangle. In this case the triangle area gets also redefined in terms of distance, since the area is a function of the height of the triangle.

Apart from perpendicularity, another important concept to talk about regarding distance is the midpoint. This is the point that is precisely in **the middle between two**. The midpoint is defined as the **point that is the same distance away from each of the points of reference**. We can and will generalize this concept in a later section, but for now, we can limit ourselves to geometry. For example the midpoint of any diameter in a circle or even a sphere is always the centre of said object.

## How to find the distance from one point to another using our distance calculator

As we have mentioned before, **distance can mean many things** but we focused this calculator on obtaining the distance between two points in 2-D space. In 2-D space, points are defined by **two coordinates each**, and that's why the distance calculator here has four text boxes for you to fill-in. Using the calculator is very straight-forward, but before you use it, we would recommend you to **get acquainted with the distance formula and the procedure** you would have to follow if it was 1950 and the Internet was still not a thing.

Suppose we have coordinates `(3,5) and (9,15)`

and we want to calculate the distance. These would be the steps you should take to calculate the 2-D distance between these two points:

- Input the values into the formula:
`√(x₂ - x₁)² + (y₂ - y₁)²`

. - Subtract values in parentheses.
- Square both quantities in parentheses.
- Add the results.
- Take the square root.
- Use the distance equation to check results.

Working the example by hand, we get `√(9-3)²+(15-5)²`

= `√36 + 100`

= `√136`

, which is approximately equal to 11.66. Note that when taking the square root you will get a positive and negative value, but since we are dealing with distance, we are **only concerned with the positive result**.

## Driving distance between cities: a real-world example (to be checked and expanded)

An application of the distance calculator is that is can be used together with the gas calculator for **making road trip plans**. Suppose you are traveling the distance between cities A and B. The only reference is city C, with route A to B perpendicular to route B to C. We can determine the distance from A to B. From this the gas calculator **will determine fuel cost**, fuel used and cost per person while traveling.

The difficulty here is to calculate the **distances between cities accurately**. A straight line (like what we use in this calculator) can be a good approximation, but it can be quite off if the route you're taking is not direct but takes some detour, maybe to avoid mountains or to pass by another city. In that case, just use Google maps or any other tool that **calculates the distance along a path** not just the distance from one point to another in a straight line.

Where our calculator can give proper measurements and predictions is when calculating distances between objects, **not the length of a path**. With this in mind, there are still multiple scenarios in which you might actually be interested in the distance between objects regardless of the path you would have to take to travel the distance from one to the other. **One such example is the distance between astronomical objects**.

## Distance from Earth to Moon and Sun, and astronomical distances

When we look at a distance within our own Earth, it is **hard to go far without bumping into some problems**. From the intrinsic curvature of this space (due to the non-zero Earth curvature) to the limited maximum distance between two point that is on the Earth. It is because this, and also because **there is a whole universe beyond our Earth**, that distances in the universe are of big interest for many people. Since we have no proper means of interplanetary traveling, let alone interstellar travels, **all we care for now as a species is the actual Euclidean distance** to some celestial objects. For example the distance from the Earth to the Sun, or the distance from Earth to the Moon.

**These distances are beyond imaginable for our ape-like brains** that have evolved, developed and grown in the very minuscule space that is the Earth in comparison with the universe. So much so that we need to use either scientific notation and/or light years, as a unit of **distance for such long lengths**. The longest trips you can do on Earth are barely a couple thousand kilometers, while the distance from Earth to the Moon, the closest astronomical object to us, is `384.000km`

. On top of that, the distance to out closes star, that is the **distance from Earth to the Sun**, is `150.000.000km`

or a little over `8 light minutes`

.

When you compare these distances with the distance to **our second nearest star (Alpha Centaury)**, which is `4 light years`

, suddenly the distance from Earth to the Sun starts to look smaller. If we want to go even more **ridiculous in comparison** we can always think about a flight from New York to Sidney, which typically takes more than `20h`

and it's merely over `16.000km`

, and we compare it with the size of the observable universe, which is about `46.600.000.000 light years`

**!!!**

Here we have inadvertently **risen a fascinating point** which is that of measuring distances not in length but in time and thus extending the notion of distance beyond its geometrical sense. We will explore this possibility further in the next section as we speak about the **importance and usefulness of distance beyond the purely geometrical sense**. This is a very interesting path to take, that is mostly inspired by the philosophical need to extend every concept to have universal meaning, as well as from the obvious physical theory to mention when talking about permutations of space and time or **any other variable that can be measured**.

## Distance beyond length

Typically the concept of distance refers to geometric Euclidean distance and it's linked to length. However you can extend the definition of **distance to mean just the difference between two things**, and then a world of possibilities opens up. Suddenly one can decide what is the best way to measure the distance between two things and to put it in terms of the most useful quantity. A very simple step to take is to think about the distance between two numbers, which **is nothing more than the 1D distance between two numbers**. To obtain the difference between two numbers we simply subtract one from the other and the result would be the difference, a.k.a. The distance.

We could jump from number distance to, for example, express this difference or distance in terms of the percentage difference which in some cases **might provide a better means of comparison**. We don't need to stay just with percentage, we can convert percentage to fraction if you feel like that would be the best way to compare of express such distance. But so far this is still just one level of abstraction in which we simply remove the units of measurement. But **what if we were to use different units altogether?**

By **extending the concept of distance to mean something closer to difference**, we can calculate the difference between two temperatures in terms of degrees or thermal energyor other related quantity like pressure. But we don't need to get some extreme, let's see how two points can be separated by a different distance **depending on the assumptions made**. Coming back to the driving distance example, we could measure the distance of the journey in time, instead of length. In this case we need an assumption to be made for the translation to be possible; namely the means of transport.

**It's not the same time that it takes to travel 10km by plane** versus the time it takes by car; or by car vs bike. Sometimes, however, the assumption is clear and implicitly agreed on, like when we measure the lightning distance in time to then convert it later to length. This rises an **interesting point, that is the fact that the conversion factor** between distances in time and length is what we call speed or velocity (mind you that they are not exactly the same thing). Truth be told, this **speed needs not be constant** as exemplified by accelerated motions such as that of a free fall under gravitational force or the one that links stopping time and stopping distance via the breaking force and drag or, in very extreme cases via the car crash force.

Another place where we find weird units of distance in solid state physics where the **distance a particle travels inside of a material** is often quoted in average "interactions" or "collisions". This distance is linked to length by using the mean free path which is the mean distance (in length) a particle travels between interactions. If we want to get even more exotic we can think about the distance from the present value to the future value of something like a car. This **distance between prices** is linked here by the car depreciation and it's not as cut and dry as the other distances, but only because of the number of factors involved in calculating this distance.

We don't want, however, to make anyone's brain explode, so please **don't think too hard about this**. Just take this calculator and use it for length-based distance in 2D space. Maybe only return to this philosophical view on distances if you ever find yourself bored and having checked all of our Omni Calculators already.