Omni Calculator logo
Last updated:

Euclidean Distance Calculator

New

Table of contents

What is the Euclidean distance?How do I calculate the Euclidean distance?Euclidean distance between two pointsEuclidean distance of three pointsEuclidean distance between a point and a lineEuclidean distance between two parallel linesA different point of view: Euclidean distance as a distance between points in a setHow do I use the Euclidean distance calculator?Euclidean distance and beyondFAQs

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 pp. We can write its coordinates as:

p=(p1,p2,p3,...)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 pp and the point qq, we apply a generalized form of the Pythagorean theorem:

 ⁣d(p,q) ⁣= ⁣(q1 ⁣ ⁣p1)2 ⁣+ ⁣(q2 ⁣ ⁣p2)2 ⁣+ ⁣=i=1n(qipi)2\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 nn 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 pp, qq, and rr, we can find the following two points distances:

d(p,q)=i=1n(qipi)2d(q,r)=i=1n(qiri)2d(p,r)=i=1n(piri)2\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=ap1+bq1+ca2+b2d=\frac{\left\lvert a\cdot p_1 +b\cdot q_1 + c\right\rvert}{\sqrt{a^2+b^2}}

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

d=mp1+q1+cm2+1d=\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=c2c1a2+b2d=\frac{\lvert c_2-c_1 \rvert}{\sqrt{a^2+b^2}}

The lines have equations:

  • a1x+b1y1+c1a_1\cdot x+b_1\cdot y_1 + c_1; and
  • a2x+b2y1+c2a_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=0d=0, we define the Euclidean distance only in the case of parallel lines. This gives us quite some helpful rules:

  • a1=a2=aa_1=a_2=a;
  • b1=b2=bb_1=b_2=b;
  • However, c1c2c_1\neq c_2.

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

d=c2c1m2+1d=\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:

FAQs

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.

Dimensions and problem type

distance between points in 2D

© Omni Calculator

First point

Second point

Check out 47 similar coordinate geometry calculators 📈
Average rate of changeBilinear interpolationCatenary curve...44 more