Connect via MCP →

Enter Calculation

Formula

Show calculation steps (1)
  1. Distance Between Points

    Distance Between Points: 3D Line Equation From Two Points Calculator

    Length of the direction vector = distance from A to B.

Advertisement

Results

Parametric Equation of the Line
x = 1 + (3)t
y = 2 + (4)t
z = 3 + (5)t
Direction vector ⟨3, 4, 5⟩
Direction component a (Δx) 3
Direction component b (Δy) 4
Direction component c (Δz) 5
Distance between points 7.0711

What This Calculator Does

This tool finds the equation of a straight line in three-dimensional space that passes through two given points, \(A=(x_1,y_1,z_1)\) and \(B=(x_2,y_2,z_2)\). A line in 3D cannot be written as a single \(y=mx+b\) formula, so we express it using a direction vector together with parametric and symmetric forms. The calculator also returns the straight-line distance between the two points.

The Formula

The direction vector points from \(A\) toward \(B\):

$$\vec{d} = \langle a, b, c \rangle = \langle x_2 - x_1,\; y_2 - y_1,\; z_2 - z_1 \rangle$$

Using \(A\) as the anchor point, the line is described parametrically with parameter \(t\):

$$\vec{r}(t) = (x_1, y_1, z_1) + t\,\langle a, b, c \rangle$$

where \(a\), \(b\), \(c\) are the direction components. The symmetric form (when none are zero) is \(\frac{x-x_1}{a} = \frac{y-y_1}{b} = \frac{z-z_1}{c}\).

Two points in 3D space connected by a line with a direction vector arrow
A line through two points P1 and P2 with direction vector v = P2 - P1.

How To Use It

Enter the three coordinates of point A and the three coordinates of point B, then read off the parametric equations and direction vector. The parameter \(t\) ranges over all real numbers: \(t=0\) gives point A and \(t=1\) gives point B.

Worked Example

Take \(A=(1,2,3)\) and \(B=(4,6,8)\). The direction vector is

$$\vec{d} = \langle 4-1,\; 6-2,\; 8-3 \rangle = \langle 3, 4, 5 \rangle$$

so the line is \(x = 1 + 3t,\; y = 2 + 4t,\; z = 3 + 5t\). The distance between the points is

$$|\vec{d}| = \sqrt{3^2 + 4^2 + 5^2} = \sqrt{50} \approx 7.071$$
Direction vector components shown as a right-angled box between two 3D points
The direction vector components a, b, c are the coordinate differences between the two points.

Step-by-Step Calculation

Given two distinct points \(A=(x_1,y_1,z_1)\) and \(B=(x_2,y_2,z_2)\), the line through them is built from a direction vector and an anchor point. Follow these five steps.

  1. Compute the direction vector components. Subtract the coordinates of \(A\) from \(B\):
    $$a = x_2-x_1,\quad b = y_2-y_1,\quad c = z_2-z_1$$
    so the direction vector is \(\vec{d}=\langle a,b,c\rangle\). This vector points from \(A\) toward \(B\).
  2. Pick an anchor point. Any point on the line works; the simplest choice is \(A=(x_1,y_1,z_1)\), giving \((x_0,y_0,z_0)=(x_1,y_1,z_1)\).
  3. Write the parametric equations. Add \(t\) times the direction vector to the anchor:
    $$x = x_1 + a\,t,\qquad y = y_1 + b\,t,\qquad z = z_1 + c\,t$$
    At \(t=0\) you are at \(A\); at \(t=1\) you are at \(B\).
  4. Form the symmetric equations. Solve each parametric equation for \(t\) and set them equal:
    $$\frac{x-x_1}{a} = \frac{y-y_1}{b} = \frac{z-z_1}{c}$$
    Zero-component handling: if a denominator is \(0\) (say \(a=0\)) you cannot divide by it. Instead drop that ratio and state the constraint directly as \(x = x_1\), then write the symmetric form using only the nonzero components.
  5. Compute the distance between the points. The distance \(|AB|\) equals the magnitude of the direction vector:
    $$|AB| = \sqrt{a^2 + b^2 + c^2}$$

More Worked Examples

Example 1 — A zero direction component

Let \(A=(2,1,5)\) and \(B=(2,4,5)\).

  1. Direction vector: \(a=2-2=0\), \(b=4-1=3\), \(c=5-5=0\), so \(\vec{d}=\langle 0,3,0\rangle\).
  2. Parametric form: \(x = 2,\ y = 1 + 3t,\ z = 5\).
  3. Symmetric form: because \(a=0\) and \(c=0\), the \(x\) and \(z\) ratios are undefined and drop out. The line is described by the constraints
    $$x = 2,\quad z = 5\quad(y\text{ free}).$$
    This is a line parallel to the \(y\)-axis.
  4. Distance: \(|AB| = \sqrt{0^2 + 3^2 + 0^2} = \sqrt{9} = \) 3.

Example 2 — Negative coordinates

Let \(A=(-3,2,-1)\) and \(B=(1,-4,5)\).

  1. Direction vector: \(a=1-(-3)=4\), \(b=-4-2=-6\), \(c=5-(-1)=6\), so \(\vec{d}=\langle 4,-6,6\rangle\).
  2. Parametric form: \(x = -3 + 4t,\ y = 2 - 6t,\ z = -1 + 6t\).
  3. Symmetric form:
    $$\frac{x+3}{4} = \frac{y-2}{-6} = \frac{z+1}{6}.$$
  4. Distance: \(|AB| = \sqrt{4^2 + (-6)^2 + 6^2} = \sqrt{16+36+36} = \sqrt{88} \approx \) 9.38.

Example 3 — A clean integer line

Let \(A=(1,0,2)\) and \(B=(4,3,2)\).

  1. Direction vector: \(a=3\), \(b=3\), \(c=0\), so \(\vec{d}=\langle 3,3,0\rangle\).
  2. Parametric form: \(x = 1 + 3t,\ y = 3t,\ z = 2\).
  3. Symmetric form (the \(z\) ratio drops because \(c=0\)):
    $$\frac{x-1}{3} = \frac{y}{3},\quad z = 2.$$
  4. Distance: \(|AB| = \sqrt{3^2 + 3^2 + 0^2} = \sqrt{18} \approx 4.24\).

Definitions & Glossary

Direction vector
The vector \(\vec{d}=\langle a,b,c\rangle\) obtained from the coordinate differences \(a=x_2-x_1\), \(b=y_2-y_1\), \(c=z_2-z_1\). It gives the orientation of the line; any nonzero scalar multiple of it describes the same line.
Parametric equation
The representation \(\vec{r}(t)=\langle x_0,y_0,z_0\rangle + t\langle a,b,c\rangle\), i.e. \(x=x_0+at,\ y=y_0+bt,\ z=z_0+ct\). Each value of \(t\) yields one point on the line.
Symmetric form
The equation \(\dfrac{x-x_1}{a}=\dfrac{y-y_1}{b}=\dfrac{z-z_1}{c}\), obtained by solving each parametric equation for \(t\) and equating. It contains no explicit parameter.
Parameter \(t\)
The free scalar that slides the point along the line. \(t=0\) gives the anchor point \(A\); \(t=1\) gives \(B\); negative \(t\) extends the line in the opposite direction.
Anchor point (base point)
Any known point on the line used as the starting position \((x_0,y_0,z_0)\). Choosing \(A=(x_1,y_1,z_1)\) is conventional, but \(B\) or any other point on the line is equally valid.
Magnitude / distance
The length \(|AB|=\sqrt{a^2+b^2+c^2}\), equal to the magnitude of the direction vector when it is built from the two given points. It measures the straight-line distance between \(A\) and \(B\).
Zero component
A direction component equal to \(0\) means the line does not change along that axis: the corresponding coordinate stays constant. Geometrically the line is parallel to the plane of the other two axes (or to one axis if two components are zero). In the symmetric form that ratio is undefined and is replaced by the constant constraint, e.g. \(x=x_1\).

FAQ

What if the two points are identical? The direction vector becomes \(\langle 0,0,0\rangle\) and no unique line exists — enter two distinct points.

Can a direction component be zero? Yes. A zero component means the line is parallel to one of the coordinate planes; the parametric form still works, but the symmetric form omits that term.

Is the equation unique? No. Any scalar multiple of the direction vector and any point on the line give a valid equivalent equation.

Last updated: