Find the distance between the points formula. Finding the distance between two points. Distance between two points in space

Calculation of the distances between points by their coordinates on the plane is elementary, on the surface of the Earth it is a little more complicated: we will consider measuring the distance and initial azimuth between points without projection transformations. First, let's understand the terminology.

Introduction

Great circle arc length - the shortest distance between any two points on the surface of the sphere, measured along the line connecting these two points (such a line is called orthodromy) and passing along the surface of the sphere or other surface of revolution. The spherical geometry differs from the usual Euclidean and the distance equations also take a different form. In Euclidean geometry, the shortest distance between two points is a straight line. On a sphere, there are no straight lines. These lines on the sphere are part of large circles - circles whose centers coincide with the center of the sphere. Initial azimuth - azimuth, taking which at the beginning of movement from point A, following the large circle for the shortest distance to point B, the end point will be point B. When moving from point A to point B along the great circle, the azimuth from the current position to the end point B is constant is changing. The initial azimuth is different from the constant one, following which, the azimuth from the current point to the final one does not change, but the route to follow is not the shortest distance between two points.

Through any two points on the surface of the sphere, if they are not directly opposite to each other (that is, they are not antipodes), a unique large circle can be drawn. Two points divide the large circle into two arcs. The length of a short arc is the shortest distance between two points. An infinite number of large circles can be drawn between two antipode points, but the distance between them will be the same on any circle and equal to half the circle's circumference, or π * R, where R is the radius of the sphere.

On a plane (in a rectangular coordinate system), large circles and their fragments, as mentioned above, are arcs in all projections, except for the gnomonic one, where large circles are straight lines. In practice, this means that aircraft and other air transport always use the route of the minimum distance between points to save fuel, that is, the flight is carried out along the distance of a large circle, on a plane it looks like an arc.

The shape of the Earth can be described as a sphere, which is why equations for calculating distances on a large circle are important for calculating the shortest distance between points on the Earth's surface and are often used in navigation. Calculating the distance by this method is more efficient and in many cases more accurate than calculating it for projected coordinates (in rectangular coordinate systems), since, firstly, for this you do not need to translate geographic coordinates into a rectangular coordinate system (carry out projection transformations) and, secondly, many projections, if incorrectly selected, can lead to significant length distortions due to the peculiarities of projection distortions. It is known that it is not a sphere, but an ellipsoid that describes the shape of the Earth more accurately, however, in this article, the calculation of the distances on the sphere is considered, for the calculations a sphere with a radius of 6372795 meters is used, which can lead to an error in calculating the distances of about 0.5%.

Formulas

There are three ways to calculate the spherical distance of a great circle. 1. Spherical cosine theorem In the case of small distances and small bit depth of calculation (the number of decimal places), the use of the formula can lead to significant rounding errors. φ1, λ1; φ2, λ2 - latitude and longitude of two points in radians Δλ - coordinate difference in longitude Δδ - angular difference Δδ \u003d arccos (sin φ1 sin φ2 + cos φ1 cos φ2 cos Δλ) To convert the angular distance to metric, you need to multiply the angular difference by the radius Earth (6372795 meters), the units of the final distance will be equal to the units in which the radius is expressed (in this case, meters). 2. Formula of Haversines Used to avoid short distance problems. 3. Modification for antipodes The previous formula is also subject to the antipode point problem, to solve it, the following modification is used.

My implementation in PHP

// Earth radius define ("EARTH_RADIUS", 6372795); / * * Distance between two points * $ φA, $ λA - latitude, longitude of the 1st point, * $ φB, $ λB - latitude, longitude of the 2nd point * Based on http://gis-lab.info/ qa / great-circles.html * Mikhail Kobzarev< > * * / function calculateTheDistance ($ φA, $ λA, $ φB, $ λB) (// convert coordinates to radians $ lat1 \u003d $ φA * M_PI / 180; $ lat2 \u003d $ φB * M_PI / 180; $ long1 \u003d $ λA * M_PI / 180; $ long2 \u003d $ λB * M_PI / 180; // cosines and sines of latitudes and differences in longitudes $ cl1 \u003d cos ($ lat1); $ cl2 \u003d cos ($ lat2); $ sl1 \u003d sin ($ lat1) ; $ sl2 \u003d sin ($ lat2); $ delta \u003d $ long2 - $ long1; $ cdelta \u003d cos ($ delta); $ sdelta \u003d sin ($ delta); // calculate the length of the great circle $ y \u003d sqrt (pow ( $ cl2 * $ sdelta, 2) + pow ($ cl1 * $ sl2 - $ sl1 * $ cl2 * $ cdelta, 2)); $ x \u003d $ sl1 * $ sl2 + $ cl1 * $ cl2 * $ cdelta; // $ ad \u003d atan2 ($ y, $ x); $ dist \u003d $ ad * EARTH_RADIUS; return $ dist;) Example of a function call: $ lat1 \u003d 77.1539; $ long1 \u003d -139.398; $ lat2 \u003d -77.1804; $ long2 \u003d -139.55; echo calculateTheDistance ($ lat1, $ long1, $ lat2, $ long2). "meters"; // Returns "17166029 meters"

Article taken from the site

There will be a calculator

Distance between two points on a straight line

Consider the coordinate line on which 2 points are marked: A A A and B B B... To find the distance between these points, you need to find the length of the segment A B AB A B... This is done using the following formula:

Distance between two points on a straight line

A B \u003d ∣ a - b ∣ AB \u003d | a-b |A B \u003d∣ a -b ∣,

where a, b a, b a, b - the coordinates of these points on a straight line (coordinate line).

Due to the fact that the formula contains a modulus, it does not matter when deciding which coordinate to subtract which one (since the absolute value of this difference is taken).

∣ a - b ∣ \u003d ∣ b - a ∣ | a-b | \u003d | b-a |∣ a -b ∣ \u003d∣ b -a ∣

Let's look at an example to better understand how to solve such problems.

Example 1

A point is marked on the coordinate line A A Awhose coordinate is 9 9 9 and point B B B with coordinate − 1 -1 − 1 ... You need to find the distance between these two points.

Decision

Here a \u003d 9, b \u003d - 1 a \u003d 9, b \u003d -1 a \u003d9, b \u003d− 1

We use the formula and substitute the values:

A B \u003d ∣ a - b ∣ \u003d ∣ 9 - (- 1) ∣ \u003d ∣ 10 ∣ \u003d 10 AB \u003d | a-b | \u003d | 9 - (- 1) | \u003d | 10 | \u003d 10A B \u003d∣ a -b ∣ \u003d∣ 9 − (− 1 ) ∣ = ∣ 1 0 ∣ = 1 0

Answer

Distance between two points on a plane

Consider two points on a plane. From each point marked on the plane, two perpendiculars must be dropped: On the axis O X OX O X and on the axis O Y OY O Y... Then the triangle is considered A B C ABC A B C... Since it is rectangular ( B C BC B C perpendicular A C AC A C), then find the segment A B AB A B, it is also the distance between points, you can use the Pythagorean theorem. We have:

A B 2 \u003d A C 2 + B C 2 AB ^ 2 \u003d AC ^ 2 + BC ^ 2A B 2 = A C 2 + B C 2

But based on the fact that the length A C AC A C equals x B - x A x_B-x_A x Bx Aand the length B C BC B C equals y B - y A y_B-y_A y By A, this formula can be rewritten as follows:

Distance between two points on a plane

A B \u003d (x B - x A) 2 + (y B - y A) 2 AB \u003d \\ sqrt ((x_B-x_A) ^ 2 + (y_B-y_A) ^ 2)A B \u003d(x Bx A) 2 + (y By A) 2 ,

where x A, y A x_A, y_A x A, y A and x B, y B x_B, y_B x B, y B - coordinates of points A A A and B B B respectively.

Example 2

You need to find the distance between the points C C C and F F Fif the coordinates of the first (8 ; − 1) (8;-1) (8 ; − 1 ) , and second - (4 ; 2) (4;2) (4 ; 2 ) .

Decision

X C \u003d 8 x_C \u003d 8 x C= 8
y C \u003d - 1 y_C \u003d -1 y C= − 1
x F \u003d 4 x_F \u003d 4 x F= 4
y F \u003d 2 y_F \u003d 2 y F= 2

CF \u003d (x F - x C) 2 + (y F - y C) 2 \u003d (4 - 8) 2 + (2 - (- 1)) 2 \u003d 16 + 9 \u003d 25 \u003d 5 CF \u003d \\ sqrt (( x_F-x_C) ^ 2 + (y_F-y_C) ^ 2) \u003d \\ sqrt ((4-8) ^ 2 + (2 - (- 1)) ^ 2) \u003d \\ sqrt (16 + 9) \u003d \\ sqrt ( 25) \u003d 5C F \u003d(x Fx C) 2 + (y Fy C) 2 = (4 − 8 ) 2 + (2 − (− 1 ) ) 2 = 1 6 + 9 = 2 5 ​ = 5

Answer

Distance between two points in space

Finding the distance between two points in this case is similar to the previous one, except that the coordinates of a point in space are set by three numbers, respectively, you need to add the coordinate of the applicate axis to the formula. The formula will look like this:

Distance between two points in space

AB \u003d (x B - x A) 2 + (y B - y A) 2 + (z B - z A) 2 AB \u003d \\ sqrt ((x_B-x_A) ^ 2 + (y_B-y_A) ^ 2 + ( z_B-z_A) ^ 2)A B \u003d(x Bx A) 2 + (y By A) 2 + (z B zA ) 2

Example 3

Find the length of a segment F K FK

Decision

F \u003d (- 1; - 1; 8) F \u003d (- 1; -1; 8)

FK \u003d (x K - x F) 2 + (y K - y F) 2 + (z K - z F) 2 \u003d (- 3 - (- 1)) 2 + (6 - (- 1)) 2 + (0 - 8) 2 \u003d 117 ≈ 10.8 FK \u003d \\ sqrt ((x_K-x_F) ^ 2 + (y_K-y_F) ^ 2 + (z_K-z_F) ^ 2) \u003d \\ sqrt ((- 3 - (- 1 )) ^ 2+ (6 - (- 1)) ^ 2+ (0-8) ^ 2) \u003d \\ sqrt (117) \\ approx10.8

According to the condition of the problem, we need to round the answer to an integer.

Maths

§2. Point coordinates on a plane

3. Distance between two points.

You and I can now talk about points in the language of numbers. For example, we no longer need to explain: take a point that is three units to the right of the axis and five units below the axis. Suffice it to say simply: take the point.

We have already said that this creates certain advantages. So, we can send a drawing made of dots by telegraph, tell it to a computer, which does not understand the drawings at all, but understands numbers well.

In the previous section, we specified some sets of points on the plane with the help of relations between numbers. Now let's try to consistently translate other geometric concepts and facts into the language of numbers.

We'll start with a simple and common task.

Find the distance between two points of the plane.

Decision:
As always, we assume that the points are given by their coordinates, and then our task is to find a rule by which we can calculate the distance between the points, knowing their coordinates. When deriving this rule, of course, it is allowed to resort to the drawing, but the rule itself should not contain any references to the drawing, but should only show what actions and in what order must be performed with these numbers - the coordinates of the points in order to get the required number - the distance between dots.

Perhaps some of the readers will find this approach to solving the problem strange and far-fetched. What is easier, they say, the points are given, even if they are coordinates. Draw these points, take a ruler and measure the distance between them.

This method is sometimes not so bad. However, imagine again that you are dealing with a computer. She does not have a ruler, and she does not draw, but she knows how to count so quickly that it does not pose any problem for her at all. Note that our task is set so that the rule for calculating the distance between two points consists of commands that the machine can execute.

It is better to solve the problem posed first for a particular case when one of these points lies at the origin. Start with a few numerical examples: find the distance from the origin of the points; and.

Indication. Use the Pythagorean theorem.

Now write a general formula for calculating the distance of a point from the origin.

The distance of a point from the origin is determined by the formula:

Obviously, the rule expressed by this formula satisfies the above conditions. In particular, it can be used for calculations on machines that can multiply numbers, add them, and extract square roots.

Now let's solve the general problem

Given two points of the plane and find the distance between them.

Decision:
Let us denote by,,, projections of points and on the coordinate axis.

The point of intersection of the lines and will be designated by a letter. From a right-angled triangle, according to the Pythagorean theorem, we obtain:

But the length of the segment is equal to the length of the segment. Points and, lie on the axis and have coordinates and, respectively. According to the formula obtained in paragraph 3 of paragraph 2, the distance between them is equal.

Arguing similarly, we find that the length of the segment is equal to. Substituting the found values \u200b\u200band into the formula we get.


Point to point distance is the length of the line segment connecting these points, at a given scale. Thus, when it comes to measuring distance, you need to know the scale (unit of length) in which the measurements will be carried out. Therefore, the problem of finding the distance from point to point is usually considered either on a coordinate line or in a rectangular Cartesian coordinate system on a plane or in three-dimensional space. In other words, most often it is necessary to calculate the distance between points by their coordinates.

In this article, we, firstly, recall how the distance from point to point on the coordinate line is determined. Next, we will obtain formulas for calculating the distance between two points of a plane or space according to given coordinates. In conclusion, let us consider in detail the solutions of typical examples and tasks.

Page navigation.

Distance between two points on a coordinate line.

Let's first define the notation. The distance from point A to point B will be denoted as.

Hence we can conclude that distance from point A with coordinate to point B with coordinate is equal to the modulus of the difference of coordinates, i.e, at any location of points on the coordinate line.

Distance from point to point on a plane, formula.

Let's get a formula for calculating the distance between points and, given in a rectangular Cartesian coordinate system on the plane.

Depending on the location of points A and B, the following options are possible.

If points A and B coincide, then the distance between them is zero.

If points A and B lie on a straight line perpendicular to the abscissa axis, then the points and coincide, and the distance is equal to the distance. In the previous paragraph, we found out that the distance between two points on the coordinate line is equal to the modulus of the difference between their coordinates, therefore, ... Hence, .

Similarly, if points A and B lie on a straight line perpendicular to the ordinate, then the distance from point A to point B is found as.

In this case, triangle ABC is rectangular in construction, and and. By pythagorean theorem we can write equality, whence.

Let's summarize all the results obtained: the distance from a point to a point on the plane is found through the coordinates of the points by the formula .

The resulting formula for finding the distance between points can be used when points A and B coincide or lie on a straight line perpendicular to one of the coordinate axes. Indeed, if A and B coincide, then. If points A and B lie on a straight line perpendicular to the Ox axis, then. If A and B lie on a straight line perpendicular to the Oy axis, then.

Distance between points in space, formula.

Let's introduce a rectangular coordinate system Oxyz in space. Let's get the formula for finding the distance from the point to the point .

In general, points A and B do not lie in a plane parallel to one of the coordinate planes. Let us draw through points A and B planes perpendicular to the coordinate axes Ox, Oy and Oz. The points of intersection of these planes with the coordinate axes will give us the projection of points A and B on these axes. We denote projections .


The desired distance between points A and B is the diagonal of the rectangular parallelepiped shown in the figure. By construction, the dimensions of this parallelepiped are and. In a high school geometry course, it was proved that the square of the diagonal of a rectangular parallelepiped is equal to the sum of the squares of its three dimensions, therefore,. Based on the information in the first section of this article, we can write the following equalities, therefore,

whence we get formula for finding the distance between points in space .

This formula is also valid if points A and B

  • match;
  • belong to one of the coordinate axes or a straight line parallel to one of the coordinate axes;
  • belong to one of the coordinate planes or a plane parallel to one of the coordinate planes.

Finding the distance from point to point, examples and solutions.

So, we got formulas for finding the distance between two points of the coordinate line, plane and three-dimensional space. It's time to consider solutions to typical examples.

The number of problems in the solution of which the final step is to find the distance between two points by their coordinates is truly enormous. A complete overview of such examples is beyond the scope of this article. Here we will restrict ourselves to examples in which the coordinates of two points are known and it is required to calculate the distance between them.

Using coordinates, they determine the location of an object on the globe. Coordinates are indicated by latitude and longitude. Latitudes are measured from the equatorial line on both sides. Latitudes are positive in the Northern Hemisphere and negative in the Southern Hemisphere. Longitude is measured from the initial meridian either to the east or to the west, respectively, it turns out either east longitude or west.

According to the generally accepted position, the meridian, which passes through the old Greenwich Observatory in Greenwich, is taken as the initial one. The geographic coordinates of the location can be obtained using a GPS navigator. This device receives signals from the satellite positioning system in the WGS-84 coordinate system, the same for the whole world.

Navigator models differ in manufacturers, functionality and interface. Currently, some models of cell phones have built-in GPS navigators. But any model can record and store the coordinates of the point.

Distance between GPS coordinates

To solve practical and theoretical problems in some industries, it is necessary to be able to determine the distances between points by their coordinates. There are several ways to do this. The canonical form of representation of geographic coordinates: degrees, minutes, seconds.

For example, you can determine the distance between the following coordinates: point # 1 - latitude 55 ° 45′07 ″ N, longitude 37 ° 36′56 ″ E; point No. 2 - latitude 58 ° 00′02 ″ N, longitude 102 ° 39′42 ″ E

The easiest way is to use a calculator to calculate the distance between two points. In the browser search engine, you must set the following search parameters: online - to calculate the distance between two coordinates. In the online calculator, latitude and longitude values \u200b\u200bare entered into the query fields for the first and second coordinates. When calculating the online calculator, the result was 3,800,619 m.

The next method is more time consuming, but also more visual. You must use any available mapping or navigation software. The programs in which you can create points by coordinates and measure the distances between them include the following applications: BaseCamp (a modern analogue of the MapSource program), Google Earth, SAS.Planet.

All of the above programs are available to any network user. For example, to calculate the distance between two coordinates in Google Earth, you need to create two placemarks with the coordinates of the first point and the second point. Then, using the Ruler tool, you need to connect the first and second marks with a line, the program will automatically display the measurement result and show the path on the satellite image of the Earth.

In the case of the example given above, the Google Earth program returned the result - the distance between point number 1 and point number 2 is 3,817,353 m.

Why there is an error in determining the distance

All distance calculations between coordinates are based on arc length calculations. The radius of the Earth is involved in calculating the arc length. But since the shape of the Earth is close to an oblate ellipsoid, the radius of the Earth at certain points is different. To calculate the distance between the coordinates, the average value of the Earth's radius is taken, which gives an error in measurement. The greater the measured distance, the greater the error.