how to find distance between two points
To find the distance between two points, you use the distance formula , which comes from the Pythagorean theorem.
Basic idea (2D)
If your two points are
A(x1,y1)A(x_1,y_1)A(x1β,y1β) and B(x2,y2)B(x_2,y_2)B(x2β,y2β), then the
distance between them is:
d=(x2βx1)2+(y2βy1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}d=(x2ββx1β)2+(y2ββy1β)2β
This is just a right triangle: one leg is the horizontal change (x2βx1)(x_2-x_1)(x2ββx1β), the other is the vertical change (y2βy1)(y_2-y_1)(y2ββy1β), and the distance is the hypotenuse.
Stepβbyβstep recipe
- Write down the coordinates
- Point A: (x1,y1)(x_1,y_1)(x1β,y1β)
- Point B: (x2,y2)(x_2,y_2)(x2β,y2β)
- Find the differences
- Horizontal change: x2βx1x_2-x_1x2ββx1β
- Vertical change: y2βy1y_2-y_1y2ββy1β
- Square the differences
- (x2βx1)2(x_2-x_1)^2(x2ββx1β)2
- (y2βy1)2(y_2-y_1)^2(y2ββy1β)2
- Add them together
- (x2βx1)2+(y2βy1)2(x_2-x_1)^2+(y_2-y_1)^2(x2ββx1β)2+(y2ββy1β)2
- Take the square root
- d=(x2βx1)2+(y2βy1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}d=(x2ββx1β)2+(y2ββy1β)2β
Quick example
Find the distance between (3,4)(3,4)(3,4) and (4,3)(4,3)(4,3):
- x_1=3,\y_1=4
- x_2=4,\y_2=3
- x_2-x_1=4-3=1
- y_2-y_1=3-4=-1
- Square: 1^2=1,\(-1)^2=1
- Add: 1+1=2
- Distance: d=\sqrt{2}\approx 1.414
Special cases
- If both points are on a horizontal line (same y): distance is |x_2-x_1|.
- If both points are on a vertical line (same x): distance is |y_2-y_1|.
In 3D (if you ever need it)
For points A(x_1,y_1,z_1) and B(x_2,y_2,z_2), the distance is:
d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}
TL;DR:
Remember this one line and youβre set:
d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}