Midpoint & Distance Calculator (2D) Formula
Understand the math behind the midpoint & distance calculator (2d). Each variable explained with a worked example.
Formulas Used
Mid X
mid_x = (x1 + x2) / 2Mid Y
mid_y = (y1 + y2) / 2Distance
distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))Slope
slope = (x2 - x1) != 0 ? (y2 - y1) / (x2 - x1) : 0Variables
| Variable | Description | Default |
|---|---|---|
x1 | Point 1 x | 2 |
y1 | Point 1 y | 3 |
x2 | Point 2 x | 8 |
y2 | Point 2 y | 7 |
How It Works
Midpoint Formula
Formula
Midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2)
The midpoint is the point exactly halfway between two given points.
Distance Formula
d = sqrt((x₂ - x₁)² + (y₂ - y₁)²)
Slope
m = (y₂ - y₁) / (x₂ - x₁)
Worked Example
Find the midpoint between (2, 3) and (8, 7).
x1 = 2y1 = 3x2 = 8y2 = 7
- 01Midpoint x = (2+8)/2 = 5
- 02Midpoint y = (3+7)/2 = 5
- 03Midpoint = (5, 5)
- 04Distance = √(36+16) = √52 ≈ 7.2111
- 05Slope = 4/6 ≈ 0.6667
Ready to run the numbers?
Open Midpoint & Distance Calculator (2D)