# Euclidean Distance Calculator

Created by Davide Borchia
Reviewed by Anna Szczepanek, PhD
Last updated: Jun 05, 2023

It may sound fancy, but the Euclidean distance is nothing more than the distance the way we think of it every day: discover more on how to calculate it with our Euclidean distance calculator!

Here you will learn:

• What is the Euclidean distance?
• Formulas:
• The distance between two points and the distance between three points;
• The distance between a point and a line;
• The distance between two lines.
• Other uses of the Euclidean distance.

## What is the Euclidean distance?

The Euclidean distance is a metric defined over the Euclidean space (the physical space that surrounds us, plus or minus some dimensions). In a few words, the Euclidean distance measures the shortest path between two points in a smooth n-dimensional space.

We can define the Euclidean distance only in flat spaces: on curved surfaces, strange things happen, and straight lines are not necessarily the shortest!

## How do I calculate the Euclidean distance?

The Euclidean distance is defined through the Cartesian coordinates of the points under analysis. We can think of it as the translation vector between two points. In our Euclidean distance calculator, we teach you how to calculate:

• The Euclidean distance between two or three points in spaces form one to four dimensions;
• The Euclidean distance between a point and a line in a 2D space; and
• The Euclidean distance between two parallel lines in a 2D space.

## Euclidean distance between two points

To find the Euclidean distance between two points. you need to know the coordinates of these points.

Take a generic point $p$. We can write its coordinates as:

$p = (p_1,p_2,p_3,...)$

The number of components depends on the dimensionality of the space.

To calculate the distance between the point $p$ and the point $q$, we apply a generalized form of the Pythagorean theorem:

\small \begin{align*} \!d(p,q)\!&=\!\sqrt{(q_1\!-\!p_1)^2\!+\!(q_2\!-\!p_2)^2\!+\!\dots}\\ \\ &=\sqrt{\sum_{i=1}^n(q_i-p_i)^2} \end{align*}

Where $n$ is the dimensionality of the space.

As you can see, it's pretty easy!

## Euclidean distance of three points

If we add a point, we will find three possible distances; three points, after all, always define a triangle (possibly degenerated).

Taking the triple of points $p$, $q$, and $r$, we can find the following two points distances:

\begin{align*} d(p,q)&=\sqrt{\sum_{i=1}^n(q_i-p_i)^2}\\ \\ d(q,r)&=\sqrt{\sum_{i=1}^n(q_i-r_i)^2}\\ \\ d(p,r)&=\sqrt{\sum_{i=1}^n(p_i-r_i)^2} \end{align*}

This concept can obviously expand to increasingly larger n-tuples.

## Euclidean distance between a point and a line

To find the distance from a point to a line (in two dimensions), we need to consider the fact that a line is nothing but a collection of points satisfying an equation. The distance between a point and a line is then the minimum distance between the point and the line.

The segment connecting the point to the point on the line satisfying the condition above is perpendicular to the line itself. To find the distance, we use this formula:

$d=\frac{\left\lvert a\cdot p_1 +b\cdot q_1 + c\right\rvert}{\sqrt{a^2+b^2}}$

Where $a$, $b$, and $c$ are the coefficient of the equation of the line in the form: $a\cdot x + b\cdot y + c = 0$. If we are considering the more commonly found expression $y = m\cdot x + c$, we would use this formula (equivalent in every way):

$d=\frac{\left\lvert m\cdot p_1 + q_1 + c\right\rvert}{\sqrt{m^2+1}}$

## Euclidean distance between two parallel lines

To calculate the distance between two parallel lines we use the following equation:

$d=\frac{\lvert c_2-c_1 \rvert}{\sqrt{a^2+b^2}}$

The lines have equations:

• $a_1\cdot x+b_1\cdot y_1 + c_1$; and
• $a_2\cdot x+b_2\cdot y_1 + c_2$.

However, there is a strong constraint over the choices of coefficients. Since two non-parallel lines would cross at a certain point in the plane, giving a trivial distance $d=0$, we define the Euclidean distance only in the case of parallel lines. This gives us quite some helpful rules:

• $a_1=a_2=a$;
• $b_1=b_2=b$;
• However, $c_1\neq c_2$.

Using the slope-intercept form of the equation of a line, the formula for the distance becomes:

$d=\frac{\lvert c_2-c_1 \rvert}{\sqrt{m^2+1}}$

## A different point of view: Euclidean distance as a distance between points in a set

The Euclidean distance is becoming an important concept in machine learning (the less sci-fi version of AI), where the distance between points in arbitrary spaces of features is measured with metrics. The most commonly used ones are:

• The Minkowski distance;
• The Manhattan distance; and
• The Euclidean distance.

Each of them is appropriate for certain data: the Manhattan distance for integer values and the Euclidean distance for real-valued data. The Minkowski distance is a generalization of both.

It is interesting to notice how a physical, and concrete, concept (the distance between two points) is translated into a distance in a space of features: the difference is from calculating the distance between your house and the one of a friend to a generalized distance between two colors, two car models...

## How do I use the Euclidean distance calculator?

First, choose the objects you are calculating the distance: for points, you can also choose the dimensionality of the space.

Then, insert the coordinates of the points or the parameters of the lines. We will show both the distance and the steps to calculate it. There is nothing more to it!

## Euclidean distance and beyond

The Euclidean distance is a particular — yet common — way to measure the distance. We made more calculator specific to certain topics and problems:

## FAQ

### What is the distance between two parallel lines with equations y = 2x + 3 and y = 2x - 4?

The distance is 3.13. To calculate it,

1. We identify the parameters of the lines:

• m=2 (the value is the same for both lines since they are parallel); and

• c₁ = 3, and c₂ = -4.

2. We apply the equation for the distance between two parallel lines:

d = | c₁ - c₂ |/(√[m² + 1])
d = | 3 + 4 |/(√[2² + 1] = 3.13

### How do I calculate the distance between a point and a line?

To calculate the distance between a point and a line, follow these steps:

1. Define the coordinates and parameters of the objects.

2. Calculate the distance using the formula:

d = | m × p₁ + q₁ + c |/(√[m² + 1])

3. And that's it! To compute the distance, we had to calculate the area of a triangle in coordinates space and then calculate its height.

### Is the distance formula still valid in a 4-dimensional space?

Yes: the concept of distance exists in any Euclidean space with an arbitrary number of dimensions. It may be hard to visualize a 4-dimensional space, though. Imagine a car that moved from a point A to a point B in a certain time t. If you take time as your fourth dimension, you can see that, if you freeze the movement, the car is not moving: we need the fourth dimension to define the distance!

### What is the distance between the point p = (1,2) and the point q = (2,3)?

d = 1.414. To calculate the distance between these two points on a plane, we simply apply the formula:

√[(p₂ - p₁)² + (q₂ - q₁)²]

In this case:

√[(2 - 1²) + (3 - 2²] = √2 = 1.414

Notice how the distance between these two particular points corresponds both to the hypotenuse of a right triangle and the diagonal of a square.

Davide Borchia Dimensions
2D
Type
2 points
First point
x₁
y₁
Second point
x₂
y₂
Result
Distance
People also viewed…

### Alien civilization

The alien civilization calculator explores the existence of extraterrestrial civilizations by comparing two models: the Drake equation and the Astrobiological Copernican Limits👽

### Distance between two points

This distance between two points calculator can instantly find the distance between two points on a two-dimensional plane!

### Helium balloons

Wondering how many helium balloons it would take to lift you up in the air? Try this helium balloons calculator! 🎈

### Quarter circle

Welcome to Omni's quarter circle calculator, a one-stop tool for all you need to know about the basics of a quarter of a circle.