Calculator

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

Use our free 3D Distance Calculator to find the distance between any two points in 3D space. Covers d = √(Δx²+Δy²+Δz²), midpoint, direction cosines, unit vectors, and 8 real-world applications — written for students, engineers, and researchers.

3D Distance Calculator

Find the straight-line distance between any two points in three-dimensional space. Enter the (x, y, z) coordinates of both points and instantly receive the 3D Euclidean distance, midpoint, direction vector, direction cosines, unit vector, and distance from origin — with full step-by-step formula explanations.

3D Distance Formula Midpoint in 3D Direction Cosines Unit Vector

🧮 3D Distance Calculator

Enter the (x, y, z) coordinates of both points. All six fields are required. The calculator applies the full 3D distance formula and returns a comprehensive geometric analysis of the segment between the two points.

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²γ
Should = 1.000
x y z A (x₁,y₁,z₁) B (x₂,y₂,z₂) d Δx = x₂−x₁ Δy Δz d_xy = √(Δx²+Δy²) d = √(Δx² + Δy² + Δz²)

Figure: The 3D distance d (orange line) is the space diagonal of the rectangular box formed by the coordinate differences Δx, Δy, and Δz. The intermediate diagonal d_xy runs across the base of the box.

📘 What Is 3D Distance? — Three-Dimensional Space Fundamentals

In three-dimensional Euclidean space (commonly called 3D space), every point is uniquely identified by three coordinates: an ordered triple (x, y, z). The x-coordinate gives horizontal position, the y-coordinate gives depth (or the second horizontal direction), and the z-coordinate gives vertical height. These three values locate a point precisely in the three mutually perpendicular dimensions that describe the physical world we live in.

The 3D distance between two such points is the length of the straight-line segment connecting them — the shortest possible path through three-dimensional space between the two locations. This distance is also called the Euclidean distance in 3D or the straight-line distance in space, to distinguish it from other distance concepts (path distance, surface distance, network distance) that are longer.

The 3D Cartesian Coordinate System

The Cartesian coordinate system in three dimensions consists of three mutually perpendicular number lines — the x-axis, y-axis, and z-axis — all passing through a common point called the origin (0, 0, 0). This was a natural extension of Descartes' 2D coordinate plane (introduced in 1637) to three dimensions, formalized in the 18th century as analytical geometry matured.

  • x-axis: Typically horizontal, pointing right (positive) or left (negative).
  • y-axis: Typically horizontal but perpendicular to x, pointing forward/away in a 3D scene, or upward in some conventions.
  • z-axis: Typically vertical, pointing up (positive) or down (negative).
  • Eight octants: The three axes divide 3D space into eight regions, analogous to the four quadrants of the 2D plane. A point's octant is determined by the signs of its coordinates: (+,+,+) is Octant I, (−,+,+) is Octant II, etc.
💡 Right-Hand Rule: In mathematics and physics, the standard orientation of 3D axes follows the right-hand rule: point your right-hand fingers along the positive x-axis, curl them toward the positive y-axis, and your thumb points in the direction of the positive z-axis. This convention is used consistently in engineering, physics, and 3D graphics (with some exceptions in specific software systems).

Why 3D Distance Matters

Understanding distance in 3D space is essential for every field that deals with physical objects, spatial data, or simulation of the real world. From the GPS in your phone (which computes distances to satellites orbiting in 3D space) to the medical imaging systems that measure distances within your body, to the physics engine of a video game computing whether a bullet reached its target — 3D distance is the fundamental measurement that ties spatial reasoning to quantitative analysis.

📐 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 = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2} \]

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}^2 = \Delta x^2 + \Delta y^2\), so \(d_{xy} = \sqrt{\Delta x^2 + \Delta y^2}\).
  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^2 = d_{xy}^2 + \Delta z^2 = \Delta x^2 + \Delta y^2 + \Delta z^2\).
  5. Take the square root: \(d = \sqrt{\Delta x^2 + \Delta y^2 + \Delta z^2}\) — the 3D distance formula.
Full Derivation — Both Pythagorean Steps \[ \text{Step 1: } d_{xy} = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} \] \[ \text{Step 2: } d = \sqrt{d_{xy}^2 + (z_2-z_1)^2} = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2} \]

The key insight is that d_xy (the 2D distance in the base plane) and Δz are perpendicular — they form a right triangle in a vertical plane. Therefore, the Pythagorean theorem applies a second time, adding (z₂−z₁)² under the same square root.

Delta Notation

Distance Formula — Delta Notation \[ \Delta x = x_2 - x_1, \quad \Delta y = y_2 - y_1, \quad \Delta z = z_2 - z_1 \] \[ d = \sqrt{(\Delta x)^2 + (\Delta y)^2 + (\Delta z)^2} = \|\vec{AB}\| \]

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

⊕ 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 = \left(\frac{x_1 + x_2}{2},\ \frac{y_1 + y_2}{2},\ \frac{z_1 + z_2}{2}\right) \]

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_2 = 2m_x - x_1, \quad y_2 = 2m_y - y_1, \quad z_2 = 2m_z - z_1 \]

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. The section formula divides AB in any ratio m:n:

3D Section Formula (Internal Division) \[ P = \left(\frac{mx_2 + nx_1}{m+n},\ \frac{my_2 + ny_1}{m+n},\ \frac{mz_2 + nz_1}{m+n}\right) \]

When m = n = 1, this reduces to the midpoint formula. P divides AB internally in the ratio m:n from point A toward point B. This formula is used in computer graphics for interpolation, in physics for center-of-mass calculations, and in geometry for Apollonius circle constructions.

🧭 Direction Vector, Direction Cosines, and Unit Vectors

The line segment from A to B in 3D has not just a length (distance) but also a direction. Three quantities fully describe this direction: the direction vector, the direction cosines, and the unit vector.

Direction Vector

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

Direction Vector \[ \vec{AB} = (x_2 - x_1,\ y_2 - y_1,\ z_2 - z_1) = (\Delta x,\ \Delta y,\ \Delta 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

The direction cosines are the cosines of the angles that the segment makes with each of the three coordinate axes. They are denoted cos α (angle with x-axis), cos β (angle with y-axis), and cos γ (angle with z-axis):

Direction Cosines \[ \cos\alpha = \frac{\Delta x}{d}, \quad \cos\beta = \frac{\Delta y}{d}, \quad \cos\gamma = \frac{\Delta z}{d} \] \[ \cos^2\alpha + \cos^2\beta + \cos^2\gamma = 1 \quad \text{(always)} \]

Direction cosines are dimensionless and always satisfy the fundamental 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

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

Unit Vector \[ \hat{u} = \frac{\vec{AB}}{d} = \left(\frac{\Delta x}{d},\ \frac{\Delta y}{d},\ \frac{\Delta z}{d}\right) = (\cos\alpha,\ \cos\beta,\ \cos\gamma) \]

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.

💡 Verification Check: Our calculator always shows the sum cos²α + cos²β + cos²γ. This should be exactly 1.000 for any valid result. If you see a value significantly different from 1, it indicates a numerical precision issue (extremely rare for practical inputs). This built-in check gives you instant confidence in the result's correctness.

🎯 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| = \|\mathbf{r}\| = \sqrt{x^2 + y^2 + z^2} \]

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). In complex number theory, for a pure imaginary 3D extension, this is the modulus.

Interpretation in Different Contexts

  • Physics: The distance from a particle at (x, y, z) to the origin is ρ = √(x² + y² + z²), used in Newton's gravitational law F = GMm/ρ².
  • 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.

🔍 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.

🌐 n-Dimensional Distance — The General Formula

The pattern established by the 2D and 3D distance formulas generalizes perfectly to any number of dimensions. In n-dimensional Euclidean space, every point is represented as an n-tuple (p₁, p₂, ..., pₙ), and the distance between two such points follows the same Pythagorean structure.

n-Dimensional Euclidean Distance Formula \[ d = \sqrt{\sum_{i=1}^{n}(q_i - p_i)^2} = \sqrt{(q_1-p_1)^2 + (q_2-p_2)^2 + \cdots + (q_n-p_n)^2} \]

Where P = (p₁, p₂, ..., pₙ) and Q = (q₁, q₂, ..., qₙ) are two points in n-dimensional space.
• n = 1: d = |q₁ − p₁| (distance on a number line)
• n = 2: d = √(Δx² + Δy²) — the 2D formula
• n = 3: d = √(Δx² + Δy² + Δz²) — the 3D formula
• n = 4, 5, ...: Abstract higher-dimensional spaces used in mathematics, physics, and data science

Machine Learning — Distance in High-Dimensional Feature Space

Modern machine learning algorithms routinely work in thousands of dimensions. In the MNIST handwritten digit recognition dataset, each 28×28 pixel image is a 784-dimensional vector. The K-Nearest Neighbors (KNN) algorithm classifies a new digit by finding the k training images with the smallest Euclidean distance in this 784-dimensional space. The distance formula, extended to n = 784, is computed millions of times during training and inference.

📌 The Curse of Dimensionality: While the distance formula extends to any dimension, high-dimensional spaces have counterintuitive properties. As dimensions increase, all points tend to become approximately equidistant from any query point, making nearest-neighbor searches less meaningful. This "curse of dimensionality" motivates dimensionality reduction techniques like PCA and t-SNE in machine learning — but the underlying distance formula remains the foundation.

🌍 Real-World Applications of 3D Distance

The 3D distance formula is one of the most widely applied mathematical tools in science, engineering, and technology. Here are the most important domains where 3D distance calculations are essential.

1. GPS — Trilateration and Satellite Navigation

Your smartphone's GPS determines your location using trilateration — measuring your distance to at least four GPS satellites simultaneously. Each satellite's position is a known 3D point in space (x, y, z in an Earth-centered coordinate system), and the GPS signal travel time gives the 3D distance to each satellite. The intersection of spheres centered at four satellite positions (each sphere radius equals the measured distance) gives your unique 3D location. The 3D distance formula is the mathematical foundation of every GPS calculation.

2. Aerospace Engineering — Orbital Mechanics

The distance between a spacecraft and another body (planet, moon, another spacecraft) in 3D space is fundamental to mission planning, gravity calculations, and docking operations. NASA's Mission Design Centers compute trajectories continuously using the gravitational force equation F = GMm/d², where d is the 3D distance. For the Parker Solar Probe approaching the Sun, or the International Space Station docking operations, 3D distance calculations are safety-critical computations performed thousands of times per second.

3. Medical Imaging — CT, MRI, and 3D Reconstruction

CT and MRI scanners produce 3D volumetric data — effectively a 3D array of voxel (3D pixel) values representing tissue density or signal intensity. Measuring the 3D distance between anatomical landmarks (for surgical planning, tumor monitoring, or prosthetics fitting) requires the full 3D distance formula applied to voxel coordinates. Surgical robots performing minimally invasive procedures use 3D distance calculations to navigate instruments through the patient's body with millimeter precision.

4. Computer Graphics and Game Development

Every modern 3D game, animated film, and virtual reality application relies constantly on 3D distance. Collision detection (has this bullet reached its target?), spatial audio (how far is the explosion?), level-of-detail (should we render this object in high resolution?), physics simulation, and AI navigation systems all use 3D distance calculations every frame. A game running at 60 FPS on a complex scene may perform millions of distance calculations per second.

5. Robotics — Path Planning in 3D Space

Industrial robots welding car frames, surgical robots operating inside the body, and autonomous drones navigating warehouses all operate in 3D space. The A* pathfinding algorithm uses 3D Euclidean distance as a heuristic to find efficient paths from current position to target, while obstacle avoidance algorithms continuously compute distances from the robot's body to surrounding objects. A drone's flight control system updates its distance calculations at hundreds of Hz to maintain stable flight.

6. Structural Engineering — 3D Modeling and Analysis

Building Information Modeling (BIM) and Finite Element Analysis (FEA) software represent structures as millions of nodes in 3D space. Computing inter-node distances is essential for generating the element stiffness matrices that determine how structures deform under load. The 3D distance formula is embedded in every structural analysis computation — from bridges to skyscrapers to airplane fuselages.

7. Particle Physics — Detector Reconstruction

At facilities like CERN, particle detectors record the 3D positions (x, y, z) of thousands of particle interactions per second. Reconstructing particle tracks, identifying decay vertices, and measuring particle momenta all require computing 3D distances between detected hits. The distance formula is one of the most frequently called functions in particle physics reconstruction software.

8. Astronomy — Stellar Distances and Galaxy Mapping

Astronomers map the 3D positions of stars and galaxies using coordinates expressed in parsecs or light-years. The 3D distance formula (combined with parallax measurements, red-shift data, and standard candles like Type Ia supernovae) allows construction of the cosmic distance ladder — the sequence of techniques used to determine distances to increasingly remote objects in the universe.

❌ Common Mistakes to Avoid

Mistake 1: Forgetting the z-Component

Applying the 2D formula d = √(Δx² + Δy²) when the problem requires the 3D formula gives a shorter — and incorrect — answer. If any of the z-coordinates are non-zero and different from each other (Δz ≠ 0), you MUST include the Δz² term. Always check whether your problem is 2D (all points share the same z-value, or z is not given) or true 3D.

⚠️ 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. A common error is to use Δ values when there are none (the origin is simply (0,0,0), so Δx = x, Δy = y, Δ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 the closest point on the infinite line AB to any 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
Unit vectorû = (Δx/d, Δy/d, Δz/d)Components = direction cosines
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
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

Notable 3D Pythagorean Triples

Δ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

❓ Frequently Asked Questions (FAQ)

What is the 3D distance formula? +
The distance between points (x₁, y₁, z₁) and (x₂, y₂, z₂) in 3D space is d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). This extends the 2D formula by adding the squared z-difference inside the square root. The formula is derived by applying the Pythagorean theorem first to the base plane (getting d_xy), then again to the vertical right triangle (getting d from d_xy and Δz).
What is the midpoint formula in 3D? +
The midpoint is M = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2). It averages each coordinate pair independently. The 3D midpoint lies exactly halfway between the two points — equidistant (d/2) from both A and B. If you know M and one endpoint, find the other: x₂ = 2m_x − x₁ (and similarly for y₂, z₂).
What are direction cosines? +
Direction cosines are the cosines of the angles (α, β, γ) that a line segment makes with the positive x, y, and z axes. For a segment with direction vector (Δx, Δy, Δz) and length d: cos α = Δx/d, cos β = Δy/d, cos γ = Δz/d. They always satisfy the fundamental identity cos²α + cos²β + cos²γ = 1. The direction cosines are identical to the components of the unit vector in the direction from A to B.
How is the 3D distance formula derived from the Pythagorean theorem? +
The derivation uses the Pythagorean theorem twice. First: in the base xy-plane, the diagonal d_xy = √(Δx² + Δy²). Second: the 3D distance d is the hypotenuse of a vertical right triangle with legs d_xy and |Δz|, giving d = √(d_xy² + Δz²) = √(Δx² + Δy² + Δz²). The key insight is that d_xy and Δz are perpendicular, allowing the Pythagorean theorem to be applied to this second right triangle without modification.
What is the distance from a point to the origin in 3D? +
Setting (x₁,y₁,z₁) = (0,0,0) in the distance formula gives d = √(x² + y² + z²). This is also called the magnitude or norm of the position vector r = (x, y, z), written ‖r‖. It appears in spherical coordinates as the radial coordinate ρ, in Newton's law as the distance between masses, and in machine learning as the L₂ norm of a feature vector.
Does the order of points matter in the 3D distance formula? +
No — d(A,B) = d(B,A) always, because each squared difference is symmetric: (x₂−x₁)² = (x₁−x₂)². The distance magnitude is always positive regardless of point order. However, the direction vector (Δx, Δy, Δz) and direction cosines DO change sign if you swap A and B — the direction reverses even though the magnitude is the same.
What is a unit vector and how is it calculated? +
A unit vector has magnitude exactly 1 and points in the same direction as the original vector. For the direction from A to B: û = (Δx/d, Δy/d, Δz/d). The magnitude of û is always 1: ‖û‖ = √((Δx/d)² + (Δy/d)² + (Δz/d)²) = √(d²/d²) = 1. Unit vectors are used to express direction without magnitude — essential in physics for normal vectors, force directions, and wavefront propagation.
Can the 3D distance formula be extended to 4D or higher dimensions? +
Yes — the formula extends to any number of dimensions n. In n-dimensional space: d = √(Σᵢ(qᵢ−pᵢ)²). Each additional dimension adds one more squared difference under the square root. The 4D case: d = √(Δx² + Δy² + Δz² + Δw²). This generalization is fundamental to theoretical physics (4D spacetime in special relativity), mathematics (Hilbert spaces), and machine learning (computing distances in high-dimensional feature spaces for KNN, clustering, and embedding models).
Shares:

Related Posts

Illustration of stacked coins and minimum wage text with dollar signs and percentages, symbolizing salary growth and income levels
Calculator

Minimum Wage

Minimum Wage Calculator Minimum Wage Calculator Select a country to see its approximate minimum wage (hourly), and then calculate estimated daily, weekly, and monthly wages. Disclaimer: This is a demo