Distance Between Parallel Lines Calculator
Find the perpendicular gap between two parallel lines in general form.
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
- Write both lines in general form ax plus by plus c equals 0.
- Make sure both equations use identical a and b values.
- Enter a and b.
- Enter the constants c1 and c2.
- Read the perpendicular distance as the main result.
- Check the normal vector length to verify the denominator.
Formula
- 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.
- The two lines share a = 3 and b = 4, so they are parallel.
- The constant difference is the absolute value of 5 minus minus 10, which is 15.
- The normal vector length is the square root of 9 plus 16, which is 5.
- Divide 15 by 5 to get a perpendicular distance of 3.
- Check by picking a point on the first line and measuring to the second.
- The tool reports distance 3, denominator 5 and difference 15.
Reference table
| a, b, c1, c2 | Normal length | Constant difference | Distance |
|---|---|---|---|
| 3, 4, 5, -10 | 5 | 15 | 3 |
| 1, 1, 2, 6 | 1.414214 | 4 | 2.828427 |
| 3, 4, 5, 5 | 5 | 0 | 0 |
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
- Purdue University, MA 460 supplement on analytic geometry
- Millersville University, lines and planes: distances
- Georgia Institute of Technology, background material on distances between lines