Uses the Euclidean distance formula to calculate the straight-line distance between two points.
The distance formula calculates the straight-line (Euclidean) distance between two points in a coordinate system. It is derived from the Pythagorean theorem and is fundamental to geometry, physics, and many other fields.
For two points (x1, y1) and (x2, y2) in a 2D plane:
d = sqrt((x2 - x1)^2 + (y2 - y1)^2)
For two points (x1, y1, z1) and (x2, y2, z2) in 3D space:
d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
The distance formula is an extension of the Pythagorean theorem:
Find the distance between points (1, 2) and (4, 6):
d = sqrt((4 - 1)^2 + (6 - 2)^2) d = sqrt(3^2 + 4^2) d = sqrt(9 + 16) d = sqrt(25) d = 5
Find the distance between points (1, 2, 3) and (4, 6, 3):
d = sqrt((4 - 1)^2 + (6 - 2)^2 + (3 - 3)^2) d = sqrt(3^2 + 4^2 + 0^2) d = sqrt(9 + 16 + 0) d = sqrt(25) d = 5
A room is 12 feet long, 9 feet wide, and 8 feet tall. Find the diagonal distance from one corner to the opposite corner:
d = sqrt(12^2 + 9^2 + 8^2) d = sqrt(144 + 81 + 64) d = sqrt(289) d = 17 feet
GPS systems use distance calculations to determine routes and estimate travel times.
Collision detection, pathfinding, and proximity calculations all rely on distance formulas.
Calculating displacement, electric field strength at a distance, and gravitational forces.
K-nearest neighbors algorithms and clustering use Euclidean distance to measure similarity between data points.