Calculator

3D Distance Calculator — Formula, Direction Cosines & Step-by-Step Guide

Calculate 3D distance, midpoint and direction cosines. Learn the formula with six worked examples, eight practice answers, diagrams and clear zero-vector and precision limits.
A cuboid with perpendicular side lengths 3, 4 and 12 has base diagonal 5 and space diagonal 13, joining A (0,0,0) to B (3,4,12).

COORDINATE GEOMETRY • DISTANCE AND DIRECTION

Find the straight-line distance, midpoint and direction between two points in 3D. Use matching units on perpendicular x, y and z axes. If the points coincide, distance is zero and direction is undefined.

d = √(Δx² + Δy² + Δz²)

A rectangular box has perpendicular edge lengths 3, 4 and 12, a base diagonal of 5, and a space diagonal of 13.
The 3–4–12 box has diagonal √(9 + 16 + 144) = 13. Perspective sketch; the formula uses actual perpendicular lengths.

3D Distance Calculator

Enter all six coordinates, using one common length unit. Decimals and scientific notation such as 1.2e-8 are accepted. Results are rounded numerical approximations.

Enter zero or a magnitude from 1e−300 to 1e300, with at most 15 significant digits. Use a decimal point and no commas or unit suffixes. Tiny nonzero results use scientific notation.

Point A  (x₁, y₁, z₁)
Point B  (x₂, y₂, z₂)
📏 3D Euclidean Distance
—
units
⊕ Midpoint
—
(x, y, z)
→ Direction Vector
—
(Δx, Δy, Δz)
|OA| Dist. from Origin
—
units
|OB| Dist. from Origin
—
units
📐 Direction Cosines & Unit Vector Components
cos α (x-axis)
—
α = —°
cos β (y-axis)
—
β = —°
cos γ (z-axis)
—
γ = —°
cos²α+cos²β+cos²γ
—
1 for distinct points; undefined at d = 0

What is 3D distance?

The 3D Euclidean distance between two points is the length of the straight segment joining them. It is the shortest path between the points in unrestricted, flat three-dimensional space. A route that follows a road, surface, or obstacle-avoiding path can be longer.

Coordinates, axes, and units

A Cartesian point is written as an ordered triple (x, y, z). The three coordinate axes are mutually perpendicular and meet at the origin (0, 0, 0). In a typical diagram, z represents height and x and y locate the point horizontally, but axis labels and orientations depend on the chosen convention.

Both points must use the same coordinate frame and the same unit of length. If x is measured in metres and y in centimetres, convert them to a common unit before calculating. The formula gives physical distance when the coordinates use perpendicular axes with consistent scales.

The xy-, xz-, and yz-coordinate planes divide space into eight octants. In the first octant, all three coordinates are positive. A point with a zero coordinate lies on a boundary plane. A standard right-handed frame uses the right-hand rule: curling from the positive x-direction toward the positive y-direction makes the thumb point along positive z.

Check the coordinate type: latitude and longitude are angles, not Cartesian distances. Map coordinates, spherical coordinates, or image indices may need conversion before this formula applies. For Cartesian coordinates, the result uses the same length unit as the inputs.

For an introduction to these coordinate planes and the distance formula, see OpenStax: Vectors in Three Dimensions (see Sources & References).

The 3D Distance Formula — Double Pythagorean Derivation

The 3D distance formula is the natural extension of the 2D formula. Its derivation is elegant: it applies the Pythagorean theorem not once but twice — first to find the diagonal across the base of a rectangular box, then again to find the full space diagonal that represents the true 3D distance.

The 3D Distance Formula d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

Where:
• d = Straight-line distance between the two points (in same units as coordinates)
• (x₁, y₁, z₁) = Coordinates of Point A
• (x₂, y₂, z₂) = Coordinates of Point B
The formula is symmetric: interchanging A and B gives the same distance.

Step-by-Step Derivation (Double Pythagorean Theorem)

  1. Set up the rectangular box. Place Point A at one corner and Point B at the diagonally opposite corner of a rectangular box (cuboid) aligned with the coordinate axes. The box's edges have lengths |Δx|, |Δy|, and |Δz|.
  2. Find the base diagonal d_xy. In the base of the box (parallel to the xy-plane), apply the 2D Pythagorean theorem to the horizontal rectangle: d_xy² = Δx² + Δy², so d_xy = √(Δx² + Δy²).
  3. Build the vertical right triangle. The base diagonal d_xy and the vertical edge |Δz| form a right triangle. The hypotenuse of this triangle is the full 3D distance d.
  4. Apply Pythagorean theorem again. d² = d_xy² + Δz² = Δx² + Δy² + Δz².
  5. Take the square root: d = √(Δx² + Δy² + Δz²) — the 3D distance formula.
Full Derivation — Both Pythagorean Steps Step 1: d_xy = √((x₂ − x₁)² + (y₂ − y₁)²) Step 2: d = √(d_xy² + (z₂ − z₁)²) = √(Δx² + Δy² + Δz²)

The displacement projected into the xy-plane is perpendicular to the vertical displacement. Their lengths are d_xy and |Δz|, so Pythagoras gives d² = d_xy² + Δz². If either length is zero, the triangle degenerates, but the same distance formula still applies.

Delta Notation

Distance Formula — Delta Notation Δx = x₂ − x₁; Δy = y₂ − y₁; Δz = z₂ − z₁ d = √(Δx² + Δy² + Δz²) = ‖AB⃗‖

In vector notation, the distance d is the magnitude (or norm) of the displacement vector AB⃗ = (Δx, Δy, Δz). The notation ‖·‖ denotes the Euclidean norm (length) of a vector.

If one or more differences are zero, the box becomes flat or collapses to a line or point. The distance formula still works.

Two right triangles show 3 squared plus 4 squared equals 5 squared, then 5 squared plus 12 squared equals 13 squared.
Apply Pythagoras twice: first across the base, then through the vertical plane.

The Midpoint Formula in 3D

Just as the 2D midpoint is the average of the two endpoints' coordinates in x and y, the 3D midpoint adds the average z-coordinate. The formula is a straightforward three-coordinate generalization:

3D Midpoint Formula M = ((x₁ + x₂)/2, (y₁ + y₂)/2, (z₁ + z₂)/2)

The midpoint M lies exactly halfway along the segment AB:
• Distance from A to M = Distance from M to B = d/2
• Each coordinate of M is the arithmetic mean of the corresponding coordinates of A and B
• The midpoint divides the segment into two equal halves in all three dimensions simultaneously

Finding a Missing Endpoint from the Midpoint

If you know the midpoint M(m_x, m_y, m_z) and one endpoint A(x₁, y₁, z₁), you can find the other endpoint B:

Finding Missing Endpoint from Midpoint x₂ = 2m_x − x₁; y₂ = 2m_y − y₁; z₂ = 2m_z − z₁

This rearrangement of the midpoint formula is used in structural engineering (finding the far end of a beam given its center), in computer graphics (reflection operations), and in mathematical proofs involving segment bisectors.

The Section Formula in 3D (Generalization)

The midpoint is the special case of dividing the segment AB in the ratio 1:1. For distinct endpoints, m > 0 and n > 0, the internal section formula gives AP:PB = m:n:

3D Section Formula (Internal Division) P = ((mx₂ + nx₁)/(m+n), (my₂ + ny₁)/(m+n), (mz₂ + nz₁)/(m+n))

When m = n = 1, this reduces to the midpoint formula. P lies between A and B and satisfies AP:PB = m:n. The coefficient on B is m/(m+n), so a larger m places P nearer B. For example, if A=(0,0,0), B=(6,3,9) and AP:PB=2:1, then P=(4,2,6).

Direction Vector, Direction Cosines, and Unit Vectors

For distinct points, the displacement from A to B has a length and a direction. The displacement vector, direction cosines and unit vector describe related aspects of this movement. When A=B, the displacement is the zero vector and no direction can be assigned.

Direction Vector

The direction vector of the segment from A to B is the displacement vector:

Direction Vector AB⃗ = (x₂ − x₁, y₂ − y₁, z₂ − z₁) = (Δx, Δy, Δz)

The direction vector points from A to B. Its magnitude is the distance d = ‖AB⃗‖. The direction vector from B to A is the negative: (−Δx, −Δy, −Δz).

Direction Cosines

For d > 0, the direction cosines use the angles between the directed displacement A→B and the positive x, y and z axes. The angles α, β and γ each lie between 0° and 180°. A negative component gives an angle greater than 90° and at most 180° with that positive axis:

Direction Cosines cos α = Δx/d; cos β = Δy/d; cos γ = Δz/d (d > 0) cos²α + cos²β + cos²γ = 1 (d > 0)

For d > 0, direction cosines are dimensionless and satisfy the identity cos²α + cos²β + cos²γ = 1. This identity follows directly from the distance formula: dividing (Δx² + Δy² + Δz²) = d² by d² gives (Δx/d)² + (Δy/d)² + (Δz/d)² = 1.

Unit Vector

For A ≠ B, the unit vector in the direction from A to B has magnitude exactly 1 and points in the same direction as the displacement. It is obtained by dividing the direction vector by the distance:

Unit Vector û = AB⃗/d = (Δx/d, Δy/d, Δz/d) = (cos α, cos β, cos γ), for d > 0

The unit vector components ARE the direction cosines. This reveals that direction cosines have a double meaning: they are both (1) the cosines of the angles with the coordinate axes and (2) the x, y, z components of the unit vector in the direction of the segment. The magnitude of the unit vector is always exactly 1: ‖û‖ = √(cos²α + cos²β + cos²γ) = √1 = 1.

Check with care. For a nonzero vector, the exact squared components sum to 1. The displayed components are rounded, so squaring those displayed values may give a nearby number. The calculator checks its unrounded internal components. This checks normalization, not whether the entered coordinates or units are correct. For identical points, neither direction nor this identity is defined.
From A(0,0,0) to B(1,2,2), displacement is (1,2,2) and distance is 3. Reversing the points negates the displacement and unit vector but keeps distance 3.
Order changes direction. It does not change the segment’s length.

Distance from a Point to the Origin in 3D

The distance from any point P(x, y, z) to the origin O(0, 0, 0) is a special case of the 3D distance formula where x₁ = y₁ = z₁ = 0:

Distance from Point to Origin (Magnitude of Position Vector) |OP| = ‖r‖ = √(x² + y² + z²)

This is also called the magnitude, norm, or length of the position vector r = (x, y, z). In physics, this appears as the distance from the origin in spherical coordinates — the radial coordinate ρ (or r).

Interpretation in Different Contexts

  • Physics: The distance from a particle at (x, y, z) to the origin is ρ = √(x² + y² + z²), used for the separation of point masses in Newton's gravitational law F = GMm/ρ² when ρ > 0.
  • Spherical coordinates: (ρ, θ, φ) — ρ is the radial distance from the origin, the 3D distance to the origin formula.
  • Machine learning: The L₂ norm of a feature vector measures how far a data point is from the zero vector — crucial in regularization and normalization.
  • Computer graphics: Testing whether a point is inside a sphere of radius R centered at the origin: the point is inside if √(x²+y²+z²) < R.

Worked Examples — Step-by-Step Solutions

Master the 3D distance formula and its related calculations through these fully solved examples. Each example is worked from first principles.

Example 1 — Basic 3D Distance

Problem: Find the distance between A(1, 2, 3) and B(4, 6, 3).

  • Δx = 4−1 = 3, Δy = 6−2 = 4, Δz = 3−3 = 0
  • Apply formula: d = √(3² + 4² + 0²) = √(9 + 16 + 0) = √25
  • Result: d = 5
  • Note: Since Δz = 0, both points lie in the same z-plane — this reduces to a 2D calculation (3-4-5 triangle).
✅ Distance = 5 units

Example 2 — True 3D Distance (All Three Differences)

Problem: Find the distance between A(1, 2, 3) and B(4, 6, 15).

  • Δx = 3, Δy = 4, Δz = 15−3 = 12
  • Base diagonal: d_xy = √(3² + 4²) = √25 = 5
  • Full 3D distance: d = √(d_xy² + Δz²) = √(25 + 144) = √169
  • Result: d = 13 (a 5-12-13 Pythagorean triple!)
✅ Distance = 13 units

Example 3 — Distance from Origin

Problem: Find the distance from P(2, 6, 9) to the origin.

  • Apply formula: d = √(2² + 6² + 9²)
  • Calculate: d = √(4 + 36 + 81) = √121
  • Result: d = 11
✅ Distance from origin = 11 units

Example 4 — Full Analysis: Distance, Midpoint, Direction Cosines

Problem: For A(0, 0, 0) and B(1, 2, 2), find the distance, midpoint, and direction cosines.

  • Δx=1, Δy=2, Δz=2
  • Distance: d = √(1² + 2² + 2²) = √(1+4+4) = √9 = 3
  • Midpoint: M = ((0+1)/2, (0+2)/2, (0+2)/2) = (0.5, 1, 1)
  • cos α = 1/3, cos β = 2/3, cos γ = 2/3
  • Verify: (1/3)² + (2/3)² + (2/3)² = 1/9 + 4/9 + 4/9 = 9/9 = 1 ✅
  • Angles: α = arccos(1/3) ≈ 70.53°, β = γ = arccos(2/3) ≈ 48.19°
✅ d = 3 | M = (0.5, 1, 1) | cos α = 1/3, cos β = cos γ = 2/3

Example 5 — Negative Coordinates

Problem: Find the distance between A(−3, −4, −5) and B(1, 2, 7).

  • Δx = 1−(−3) = 4, Δy = 2−(−4) = 6, Δz = 7−(−5) = 12
  • Apply formula: d = √(4² + 6² + 12²) = √(16 + 36 + 144) = √196
  • Result: d = 14
✅ Distance = 14 units
🎯 Three-Step Strategy: (1) Compute Δx, Δy, Δz separately, watching sign when subtracting negatives. (2) Square each — this eliminates all sign information. (3) Add and take the square root. Check your answer against known Pythagorean triples (3-4-5, 5-12-13, 8-15-17) when possible for integer-coordinate problems.

Example 6 — Convert units before calculating

A floor plan gives a horizontal offset of 3 m and 4 m. The vertical rise is 1200 cm. Convert 1200 cm ÷ 100 = 12 m. Then d = √(3² + 4² + 12²) = √169 = 13 m. Squaring 1200 alongside 3 and 4 would mix centimetres and metres.

Use the length converter to put every coordinate difference in the same unit first.

2D vs. 3D Distance — Key Differences and Connections

Understanding how the 2D and 3D distance formulas relate — and differ — builds deep intuition for coordinate geometry and prepares you for higher-dimensional generalizations.

Feature2D Distance3D Distance
Input coordinates(x₁, y₁) and (x₂, y₂)(x₁, y₁, z₁) and (x₂, y₂, z₂)
Formulad = √(Δx² + Δy²)d = √(Δx² + Δy² + Δz²)
Midpoint((x₁+x₂)/2, (y₁+y₂)/2)((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)
Pythagorean derivation1 application2 applications (base diagonal, then vertical)
Direction angle1 angle θ from +x axis (atan2)3 direction angles α, β, γ (one per axis)
Direction cosine identitycos²θ + sin²θ = 1cos²α + cos²β + cos²γ = 1
Distance from origin√(x² + y²)√(x² + y² + z²)
Number of octants/quadrants4 quadrants8 octants
Special casez₁ = z₂ = 0 in 3D formulaReduces to 2D when Δz = 0
💡 Key Connection: The 2D formula is a special case of the 3D formula with Δz = 0. The 3D formula is a special case of the n-D formula with n = 3. Every higher-dimensional formula simply adds one more squared difference under the same square root — the Pythagorean theorem scales perfectly to any number of dimensions.

Direction angles require a nonzero displacement. In 3D the three direction angles are constrained by cos²α + cos²β + cos²γ = 1.

For a planar example, use the 2D distance calculator. For speed–time–distance questions and other coordinate modes, see the distance tools guide.

Distance in four or more dimensions

For points P = (p₁, p₂, …, pₙ) and Q = (q₁, q₂, …, qₙ) in n-dimensional Euclidean space, subtract matching coordinates, square the differences, add them, and take the square root:

n-dimensional Euclidean distance

d = √[(q₁ − p₁)² + (q₂ − p₂)² + … + (qₙ − pₙ)²]

  • In one dimension, d = |q₁ − p₁|.
  • In two dimensions, d = √(Δx² + Δy²).
  • In three dimensions, add Δz² under the square root.
  • In four Euclidean dimensions, d = √(Δx² + Δy² + Δz² + Δw²).

Feature vectors in data analysis

A data point can have many numerical features. Euclidean distance is one way to compare such vectors, including in some nearest-neighbor methods. Scaling matters: a feature measured in large numerical units can dominate the result unless the data are suitably prepared. Nearest-neighbor methods can also use other metrics; see the scikit-learn nearest-neighbors guide (see Sources & References).

In some high-dimensional datasets, distances become relatively similar and nearest-neighbor comparisons become less informative. This depends on the data and its underlying structure, rather than dimension alone. Cornell’s nearest-neighbors notes (see Sources & References) illustrate both distance concentration and low-dimensional structure.

Euclidean space is the assumption: the four-dimensional formula above is not the spacetime interval of special relativity. That interval treats the time term differently; OpenStax’s discussion of Lorentz transformations (see Sources & References) explains the distinction.

Where 3D distance is used

Euclidean separation is a useful building block when positions are expressed in a suitable Cartesian coordinate frame. Real systems may also need uncertainty estimates, coordinate transformations, or a model of the allowed route.

1. GPS and satellite navigation

Navigation calculations include the geometric range from a receiver to a satellite. A basic GPS solution uses measurements from at least four satellites to estimate three position coordinates and the receiver’s clock offset. Real measurements also contain errors, so this is more than intersecting four perfect spheres. See NASA’s introduction to satellite navigation (see Sources & References), the position-solution slide numbered 30.

2. Aerospace and orbital mechanics

If two spacecraft positions are expressed in the same Cartesian frame at the same time, the norm of their relative-position vector gives their spatial separation. In a Newtonian point-mass model, the inverse-square gravitational force also depends on the separation between the masses. Trajectory prediction needs additional dynamics and timing information.

3. Medical imaging

Distances between image landmarks should be calculated in physical coordinates, such as millimetres. Raw voxel indices may have unequal spacing by axis and do not automatically give physical length. Image position, orientation, and spacing supply the conversion, as described in the DICOM Image Plane Module (see Sources & References). Clinical measurements require appropriately validated tools and imaging context.

4. Computer graphics and games

Distance can help determine whether an object is within a range, how sound changes with separation, or which level of detail to render. For example, a point is on or inside a sphere of radius R centred at C when its distance from C is at most R. General collision detection also depends on object shapes and motion.

5. Robotics and path planning

Straight-line distance measures separation between a robot’s current position and a target in a shared spatial frame. An obstacle-avoiding route may be longer. Euclidean distance can serve as a lower-bound heuristic in path search when the movement costs and permitted motions make that bound valid.

6. Structural engineering

In a three-dimensional model, the distance between a beam’s endpoints gives its length. Its displacement vector gives its orientation. Structural analysis uses these geometric quantities alongside loads, material properties, and the assumptions of the chosen element or structural model.

7. Particle-detector reconstruction

Recorded detector-hit positions can be compared in a common coordinate frame. Their separations can contribute to grouping hits and reconstructing particle tracks. Distance alone does not determine a track: measurement uncertainty, detector geometry, and particle-motion models also matter.

8. Astronomy and spatial mapping

Positions of nearby objects represented in a suitable Cartesian model can be compared using Euclidean distance, with a consistent unit such as parsecs. Determining those positions is a separate measurement problem. Cosmological distances involve additional models and should not be treated as a direct application of this calculator to redshift or sky angles.

Common Mistakes to Avoid

Mistake 1: Forgetting the z-Component

When Δz ≠ 0, applying only d = √(Δx² + Δy²) computes the xy-plane projection length and underestimates the full 3D distance. Whenever Δz ≠ 0, include Δz², even if one z-coordinate is zero. Equal z-coordinates make this term zero. A missing z-coordinate does not by itself prove that the points have equal height.

⚠️ Example: Distance between A(1,2,3) and B(4,6,15).
Wrong (2D formula): d = √(3² + 4²) = √25 = 5 ✗
Correct (3D formula): d = √(3²+4²+12²) = √(9+16+144) = √169 = 13 ✅

Mistake 2: Sign Errors with Negative Coordinates

Subtracting a negative coordinate: x₂ − x₁ = 3 − (−5) = 3 + 5 = 8, NOT 3 − 5 = −2. This is the same error as in 2D, but with an extra coordinate it creates three separate opportunities for sign mistakes. Always write out all three differences explicitly before squaring.

Mistake 3: Forgetting to Square Each Difference Individually

√(Δx + Δy + Δz) is NOT the distance formula. Each of the three differences must be squared BEFORE summing. The correct formula squares each: √(Δx² + Δy² + Δz²). This is the Pythagorean theorem applied twice — the squaring is fundamental to its derivation.

Mistake 4: Computing Partial Distance from Origin Incorrectly

The distance from point (x, y, z) to the origin is √(x² + y² + z²), using the point's actual coordinate values. The coordinate differences are still present: subtracting the origin gives Δx=x, Δy=y and Δz=z. Also, never forget the z term — even if the point is on the xy-plane (z = 0), confirm z = 0 explicitly before dropping the z term.

Mistake 5: Confusing Direction Cosines with the Actual Angles

Direction cosines are the cosines of the angles, not the angles themselves. To find the angle α, you must take the inverse cosine: α = arccos(Δx/d). Writing "α = Δx/d" confuses the cosine with the angle. A direction cosine can range from −1 to +1; an angle ranges from 0° to 180°.

Mistake 6: Assuming the Midpoint Formula Gives the Closest Point on a Line

The midpoint formula gives the point exactly halfway between A and B along the segment AB — it is not generally the closest point on the infinite line AB to a given external point. Computing the closest point on a line to an external point requires the more complex foot of perpendicular formula (projection formula), which is different from and more complex than the midpoint formula.

Quick Reference Table

PropertyFormula in 3DNotes
3D Distanced = √(Δx² + Δy² + Δz²)Primary formula — Pythagorean theorem applied twice
MidpointM = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)Average of each coordinate pair
Direction Vectorv⃗ = (Δx, Δy, Δz)Points from A to B
Distance from origin|OP| = √(x² + y² + z²)Magnitude of position vector
Direction cosinescos α = Δx/d, cos β = Δy/d, cos γ = Δz/dSatisfy cos²α + cos²β + cos²γ = 1 Requires d > 0; undefined for identical points.
Unit vectorû = (Δx/d, Δy/d, Δz/d)Components = direction cosines Requires d > 0; undefined for identical points.
Base diagonald_xy = √(Δx² + Δy²)Intermediate 2D distance in xy-plane
Section formula (m:n)P = ((mx₂+nx₁)/(m+n), (my₂+ny₁)/(m+n), (mz₂+nz₁)/(m+n))Internal division; midpoint: m=n=1 AP:PB=m:n with A≠B and m,n>0.
Missing endpointx₂ = 2m_x − x₁ (similarly y₂, z₂)Given midpoint M and one endpoint A
n-D generalizationd = √(Σᵢ(qᵢ−pᵢ)²)2D: n=2; 3D: n=3

Integer 3D distances: Pythagorean quadruples

ΔxΔyΔzDistance dHow to Verify
1223√(1+4+4) = √9 = 3
2367√(4+9+36) = √49 = 7
341213√(9+16+144) = √169 = 13
26911√(4+36+81) = √121 = 11
461214√(16+36+144) = √196 = 14
1489√(1+16+64) = √81 = 9

Practice: eight problems with worked answers

Try each problem before opening its solution. Unless a problem specifies a unit, report distance in units. Keep the exact radical until the final rounding step.

1. Three nonzero coordinate differences

Find the distance and midpoint between A(0, 1, −2) and B(2, 4, 4).

Show worked answer

The displacement is B − A = (2 − 0, 4 − 1, 4 − (−2)) = (2, 3, 6).

d = √(2² + 3² + 6²) = √(4 + 9 + 36) = √49 = 7 units.

M = ((0 + 2)/2, (1 + 4)/2, (−2 + 4)/2) = (1, 2.5, 1).

2. Negative coordinates and an exact radical

Find the distance between A(−4, 3, −2) and B(2, −5, 1). Give an exact answer and a decimal to four places.

Show worked answer

Δx = 2 − (−4) = 6, Δy = −5 − 3 = −8, and Δz = 1 − (−2) = 3.

d = √(6² + (−8)² + 3²) = √(36 + 64 + 9) = √109 units ≈ 10.4403 units.

The negative y-difference is squared; it contributes +64, not −64.

3. Convert the units before calculating

A drone ends 1.5 m east, 200 cm north, and 2 m above its starting point. What is its straight-line displacement length?

Show worked answer

Use metres throughout: 200 cm = 2 m. The perpendicular displacement components are therefore (1.5, 2, 2) m.

d = √(1.5² + 2² + 2²) m = √10.25 m = (√41)/2 m ≈ 3.2016 m.

This is the separation of the endpoints. The distance actually flown depends on the drone’s route and is at least this large.

4. Equal heights

Find the distance between A(−2, 1, 7) and B(4, 9, 7). Why can a two-dimensional calculation work here?

Show worked answer

The differences are (6, 8, 0), so d = √(6² + 8² + 0²) = √100 = 10 units.

Both points lie in the plane z = 7. Their z-difference is zero even though neither z-coordinate is zero, so the distance equals the length of their projection onto the xy-plane.

5. A direction with a negative component

For A(−1, 2, 3) and B(1, −2, 7), find the distance, midpoint, and unit vector from A to B. Then find the three direction angles.

Show worked answer

B − A = (2, −4, 4), so d = √(4 + 16 + 16) = 6 units.

M = ((−1 + 1)/2, (2 − 2)/2, (3 + 7)/2) = (0, 0, 5).

Dividing the displacement by 6 gives û = (1/3, −2/3, 2/3). These components are also the direction cosines.

Check: (1/3)² + (−2/3)² + (2/3)² = 1/9 + 4/9 + 4/9 = 1.

Measured from the positive coordinate axes, α = arccos(1/3) ≈ 70.53°, β = arccos(−2/3) ≈ 131.81°, and γ = arccos(2/3) ≈ 48.19°. The negative y-component produces an obtuse angle with the positive y-axis.

6. Recover the missing endpoint

A segment has endpoint A(−3, 2, 0) and midpoint M(2, −1, 4). Find its other endpoint B and its length.

Show worked answer

B = 2M − A = (2·2 − (−3), 2·(−1) − 2, 2·4 − 0) = (7, −4, 8).

B − A = (10, −6, 8), so d = √(100 + 36 + 64) = √200 = 10√2 units ≈ 14.1421 units.

Check the midpoint: ((−3 + 7)/2, (2 − 4)/2, (0 + 8)/2) = (2, −1, 4).

7. Two possible values of an unknown coordinate

The distance between A(1, 2, 3) and B(4, 6, z) is 13 units. Find every possible value of z.

Show worked answer

13² = (4 − 1)² + (6 − 2)² + (z − 3)², so 169 = 9 + 16 + (z − 3)².

Thus (z − 3)² = 144 and z − 3 = ±12. The two answers are z = 15 or z = −9.

Both give a vertical separation of 12 units from A. Squaring loses the sign of that vertical difference, which is why both solutions must be considered.

8. Identical points

Let A = B = (2, −3, 4). Find the distance, midpoint, displacement vector, and distance to the origin. Does the segment have a unit direction vector?

Show worked answer

B − A = (0, 0, 0), so the distance is 0 units and the midpoint is (2, −3, 4).

Each point is √(2² + (−3)² + 4²) = √29 units ≈ 5.3852 units from the origin.

The segment’s unit direction vector, direction cosines, and direction angles are undefined. Computing them would require dividing by its zero length. Zero distance does not mean the shared point is the origin.

Frequently asked questions

What is the 3D distance formula?

For A(x₁, y₁, z₁) and B(x₂, y₂, z₂), d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. Use Cartesian coordinates in the same frame and length unit. The result is the straight-line separation, which is zero when the points coincide.

What is the midpoint formula in 3D?

The midpoint is M = ((x₁ + x₂)/2, (y₁ + y₂)/2, (z₁ + z₂)/2). Average each pair of corresponding coordinates. Its distance from either endpoint is half the full segment length. If M and A are known, the missing endpoint is B = 2M − A, applied coordinate by coordinate.

What are direction cosines?

For distinct points, the direction cosines of the vector from A to B are Δx/d, Δy/d, and Δz/d. They are the cosines of its angles with the positive x-, y-, and z-axes, and their squares sum to 1. They are undefined when A = B because d = 0.

How is the 3D distance formula derived from the Pythagorean theorem?

First find the projected distance in the xy-plane: dxy = √(Δx² + Δy²). The projected displacement is perpendicular to the vertical displacement. Apply Pythagoras again: d = √(dxy² + Δz²) = √(Δx² + Δy² + Δz²).

What is the distance from a point to the origin in 3D?

For P(x, y, z), the origin is O(0, 0, 0), so the coordinate differences are x, y, and z. Therefore OP = √(x² + y² + z²). This is the length of the position vector. It equals zero only at the origin.

Does the order of points matter in the 3D distance formula?

No. Reversing A and B changes the signs of all three differences, but their squares stay the same, so d(A, B) = d(B, A). Distance is nonnegative. For distinct points, reversing the order reverses the displacement and unit vectors and changes the signs of the direction cosines.

What is a unit vector and how is it calculated?

A unit vector has length 1. If A and B are distinct, divide their displacement vector by its length: û = (Δx/d, Δy/d, Δz/d). It points from A to B, and its components equal the direction cosines. If the points coincide, that direction and its unit vector are undefined.

Can the 3D distance formula be extended to 4D or higher dimensions?

Yes, in Euclidean space: square and add every corresponding coordinate difference, then take the square root. In four Euclidean dimensions, d = √(Δx² + Δy² + Δz² + Δw²). This all-plus formula does not describe the spacetime interval of special relativity.

Sources & References

Mathematical definitions and application limits checked on 5 October 2026. Explanations, examples and diagrams on this page are original teaching material.

These references explain the underlying mathematics and the application limits discussed above.

Original site resources

Shares:

Related Posts