Math
3D Distance Calculator
Enter two points (x, y, z) and mathcheck applies the 3D distance formula, showing the differences, the squared sum, and the simplified radical answer with a decimal.
It also returns the midpoint of the segment, the direction vector from the first point to the second, the unit direction, and the angles that direction makes with each axis.
Try an example
Result
Distance PQ
—
- Decimal
- —
- Midpoint
- —
- Direction vector P → Q
- —
- Unit direction
- —
- Direction angles
- —
- Distance ignoring z (xy-plane)
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
The 3D distance formula
Distance in three dimensions extends the Pythagorean theorem twice: first across the floor (x and y), then up the z-axis. The result is the straight-line distance between the points, the length of the diagonal of the box whose opposite corners are the two points.
P(1, 2, 3) to Q(4, 6, 15)
Δx = 3, Δy = 4, Δz = 12. d = sqrt(9 + 16 + 144) = sqrt(169) = 13. Midpoint = (2.5, 4, 9). Direction vector ⟨3, 4, 12⟩, unit direction ⟨3/13, 4/13, 12/13⟩.
| Situation | What the formula becomes |
|---|---|
| Same z for both points | the ordinary 2D distance formula |
| Points differ in one coordinate only | the absolute difference of that coordinate |
| One point is the origin | the magnitude of the other point's position vector |
How to use this calculator
- Enter the x, y, z coordinates of point P.
- Enter the coordinates of point Q.
- Read the distance as a simplified A root expression written with the √ symbol, such as a square root. with its decimal.
- Use the The point exactly halfway between two other points., direction vector, or direction angles if your problem asks for them.
- Open Show the work to see the differences and the squared sum.
How to read the answer
The distance is the length of the straight segment joining the two points and is always zero or positive. An exact radical such as 2√14 is the textbook answer; the decimal is for measurement. The midpoint sits halfway along the segment, and the unit direction vector describes which way the segment points without its length.
Common mistakes and edge cases
- Leaving out the z-term and getting the flat (xy-plane) distance instead; the calculator shows both so you can see the difference.
- Forgetting to square the differences before adding.
- Squaring a negative difference and getting a negative number: (-4)^2 is 16.
- Adding the coordinates instead of averaging them for the midpoint.
- Mixing up which point is first when writing the direction vector.
Worked examples
Whole-number distance
P(1, 2, 3) and Q(4, 6, 15)
Distance PQ
13
Radical distance
P(0, 0, 0) and Q(2, 3, 4)
Distance PQ
√29 (5.3852)
Simplified radical
P(-1, 2, 5) and Q(3, -2, 1)
Distance PQ
4√3 (6.9282)
Same z (2D case)
P(1, 1, 7) and Q(4, 5, 7)
Distance PQ
5
Decimal coordinates
P(0.5, 1.5, 2) and Q(2.5, 1.5, 2)
Distance PQ
2
Identical points
P = Q = (3, 3, 3)
Distance PQ
0
Frequently asked questions
What is the distance formula in 3D?+
d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2). It is the Pythagorean theorem applied to the three coordinate differences.
How do I find the midpoint of two 3D points?+
Average each coordinate separately: ((x1 + x2)/2, (y1 + y2)/2, (z1 + z2)/2).
Does the order of the points matter?+
Not for distance or midpoint. It does matter for the direction vector, which goes from the first point to the second; swapping the points reverses it.
Why is my answer a square root?+
Unless the squared differences add up to a perfect square, the exact distance is an irrational number. The calculator simplifies the radical and also gives a decimal.
What are direction angles?+
The angles α, β, γ that the segment makes with the positive x-, y-, and z-axes. Their cosines are the components of the unit direction vector.
Can I use this for 2D points?+
Yes. Enter the same z-value for both points (for example 0) and the formula reduces to the ordinary 2D distance formula.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Distance Formula Calculator
Find the distance between two coordinate points with dx, dy, squared distance, and square-root steps.
Midpoint Calculator
Find the midpoint between two coordinate points with coordinate-average steps.
Vector Magnitude and Direction Calculator
Find the magnitude (length) and direction angle of a 2D or 3D vector from its components or from two points. Exact radical magnitude, unit vector, direction cosines, and an arrow diagram.
Distance from Point to Line Calculator
Find the perpendicular distance from a point to a line in 2D (any line form) or from a point to a plane in 3D, with the exact radical form, the foot of the perpendicular, and formula steps.
Unit Vector Calculator
Normalize a 2D or 3D vector to a unit vector with exact rationalized radical components and decimals, plus the magnitude, direction angle, and the opposite unit vector.
Pythagorean Theorem Calculator
Solve a² + b² = c² for the hypotenuse or either leg with exact radical form (√50 = 5√2) and decimals, plus area, perimeter, both acute angles, a Pythagorean-triple check, steps, and a squares-on-sides diagram.
Last updated: September 4, 2026