Distance Between Parallel Lines Calculator

Find the perpendicular gap between two parallel lines in general form.

Math and PercentUpdated 2026-11-192 min read
Distance Between Parallel Lines Calculator
The x coefficient, shared by both parallel lines.
The y coefficient, shared by both parallel lines.
The constant in the first line ax plus by plus c1 equals 0.
The constant in the second line ax plus by plus c2 equals 0.
Perpendicular distance
...
Square root of a squared plus b squared...
Absolute difference of constants...
First line...
Second line...

What it does

Two parallel lines can be written with the same x and y coefficients and different constants. The shortest distance between them is measured along a line perpendicular to both, and it depends only on how far apart the constants are.

This tool takes the shared coefficients a and b plus the two constants c1 and c2. It returns the perpendicular distance, the absolute constant difference, and the length of the normal vector that appears in the denominator.

The page opens with 3x plus 4y plus 5 equals 0 and 3x plus 4y minus 10 equals 0. The normal vector has length 5 and the constants differ by 15, so the distance is 3.

The formula assumes both equations use exactly the same a and b. If you have equations with scaled coefficients, divide both sides of one equation by a common factor first so the coefficients match.

The distance is a length in whatever coordinate units the line equations use. It is not the horizontal or vertical gap, which would generally be longer.

How to use

  1. Write both lines in general form ax plus by plus c equals 0.
  2. Make sure both equations use identical a and b values.
  3. Enter a and b.
  4. Enter the constants c1 and c2.
  5. Read the perpendicular distance as the main result.
  6. Check the normal vector length to verify the denominator.

Formula

d = |c1 - c2| / sqrt(a squared + b squared)
a, b
The shared coefficients of x and y in both line equations.
c1, c2
The constant terms in the first and second line.
d
The perpendicular distance between the lines.

The denominator sqrt(a squared plus b squared) is the length of the normal vector to the lines. Dividing by it converts the difference in equation constants into a true geometric distance. If both a and b are zero there is no line, so the tool reports an error.

Worked example

Example: 3x plus 4y plus 5 and 3x plus 4y minus 10

The page opens with a = 3, b = 4, c1 = 5 and c2 = -10.

  1. The two lines share a = 3 and b = 4, so they are parallel.
  2. The constant difference is the absolute value of 5 minus minus 10, which is 15.
  3. The normal vector length is the square root of 9 plus 16, which is 5.
  4. Divide 15 by 5 to get a perpendicular distance of 3.
  5. Check by picking a point on the first line and measuring to the second.
  6. The tool reports distance 3, denominator 5 and difference 15.

Reference table

Distances between sample parallel lines
a, b, c1, c2Normal lengthConstant differenceDistance
3, 4, 5, -105153
1, 1, 2, 61.41421442.828427
3, 4, 5, 5500

Limits

  • Requires exactly matching a and b coefficients in both equations.
  • Coefficients are limited to plus or minus 1,000,000,000.
  • The distance uses the same length unit as the coordinates.
  • The result is the perpendicular distance, not a horizontal or vertical offset.

Common mistakes

  • Using different a and b values for the two lines.
  • Forgetting the absolute value around the constant difference.
  • Dividing by a plus b instead of the square root of a squared plus b squared.
  • Reporting a horizontal gap rather than a perpendicular distance.
  • Ignoring a common factor that should be divided out first.

Try it yourself

Quick checks. Answers sit tucked under each question.

Lines x plus y plus 2 and x plus y plus 6. Distance?

2.828427. The constants differ by 4 and the normal length is the square root of 2.

Lines with equal constants. Distance?

0. The two equations describe the same line.

3x plus 4y plus 5 and 3x plus 4y minus 10. Distance?

3, from 15 divided by 5.

Questions

What form must the equations use?

General form ax plus by plus c equals 0, with identical a and b for both lines.

What if my coefficients are scaled?

Rescale one equation so a and b match exactly before entering the constants.

Is this the shortest distance?

Yes. It is measured along the normal to the lines.

Can the distance be zero?

Yes, when the two constants are equal and the lines coincide.

Does the coordinate unit matter?

No. The distance uses the same unit as the coordinates.

What if a and b are both zero?

That is not a valid line, and the tool reports an error.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.