Library / Geometry, coordinates, surveying and trigonometry / GEO-27
Geometry, coordinates, surveying and trigonometry
Perpendicular distance from a point to a line
Shortest distance from the point (x, y) to the line Ax + By + C = 0.
- Ref
- GEO-27
- Rev
- v1
- Field
- Geometry, coordinates, surveying and trigonometry
- Result
- d [cm]
The perpendicular distance from the point (x, y) to the line Ax + By + C = 0 is |Ax + By + C| divided by √(A² + B²). The numerator measures how far the point is from satisfying the line equation, and the denominator turns that into a true length. A and B cannot both be zero. It also works for vertical and horizontal lines.
Shortest distance from the point (x, y) to the line Ax + By + C = 0. A and B cannot both be zero. It works for vertical and horizontal lines.
Calculator
- Value of Ax + By + C (signed; its sign gives the side of the line)−5 cm
- Length of the normal vector, √(A² + B²)5
- Gradient of the line, −A/B (shown as 0 for a vertical line)−0.75
What drives the result
Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.
- The point (0, 0) is 1 cm from the line 3x + 4y + (−5) = 0; for 3x + 4y − 5 = 0 the origin is exactly 1 cm away.
- A signed value tells which side of the line the point is on, which is how a point is tested against a boundary.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing (cm) | Local step | Change in result |
|---|---|---|---|---|---|---|
| y Point y | −10 to 10 cm | 0.06667 | 9 | 8.933 | +0.4 cm | −32 % |
| x Point x | −10 to 10 cm | 0.2 | 7 | 6.8 | +0.4 cm | −24 % |
| C Line constant C | −20 to 20 cm | 0 | 4 | 4 | +0.8 cm | −16 % |
| B Line coefficient B | −6 to 6 | 0.7454 | 1.667 | 0.9213 | +0.24 | −3.74 % |
| A Line coefficient A | −6 to 6 | 0.6934 | 1.25 | 0.5566 | +0.24 | −2.87 % |
Sweep of Line constant C
| Line constant C (cm) | Distance to the line (cm) |
|---|---|
| −20 | 4 |
| −15 | 3 |
| −10 | 2 |
| −5 | 1 |
| 0 | 0 |
| 5 | 1 |
| 10 | 2 |
| 15 | 3 |
| 20 | 4 |
Sweep one variable
Variables and how each one contributes
Distance to the line
What the equation gives you. Everything else feeds it.
Line coefficient A
The coefficient of x in the line equation, a plain number. Changes both the slope of the line and the distance, and not in proportion. Raising it by 0.5 (to 3.5) moves the result by −5.93 %, from 1 to 0.9407 cm.
Line coefficient B
The coefficient of y in the line equation, a plain number. Changes both the slope of the line and the distance, and not in proportion. Raising it by 0.5 (to 4.5) moves the result by −7.55 %, from 1 to 0.9245 cm.
Line constant C
The constant of the line equation, in cm. Shifts the line, which changes the distance in proportion when the point is on one side. Raising it by 0.5 (to −4.5) moves the result by −10 %, from 1 to 0.9 cm.
Point x
The x-coordinate of the point, in cm. Moves the point relative to the line. Raising it by 0.5 (to 0.5) moves the result by −30 %, from 1 to 0.7 cm.
Point y
The y-coordinate of the point, in cm. Moves the point relative to the line. Raising it by 0.5 (to 0.5) moves the result by −40 %, from 1 to 0.6 cm.
Worked example with the values above
- Substitute into the line: A x + B y + C = 3 × 0 + 4 × 0 + −5 = −5.
- Length of the normal: √(A² + B²) = 5.
- d = 5 / 5 = 1 cm.
Assumptions and limits
- Plane (two-dimensional) Cartesian coordinates in one consistent unit.
- The two points or the two direction vectors are not the same, and neither vector has zero length.
Common mistakes
- Forgetting the absolute value, which gives a signed distance.
- Using a line written as y = mx + c without first moving every term to one side.
- Dividing by A + B instead of √(A² + B²).
Statistics and uncertainty
These are exact algebraic results from the coordinates, so the uncertainty comes from the inputs. Near-parallel lines and nearly collinear points are the cases where small input errors give large changes in angles or areas.
Where it is used
- Clearances, offsets and angles between members in drawings, CAD and surveying.
- Areas of plots, plates and polygon pieces from corner coordinates.
Maths you need
- Gradient: rise over run of a line
- Vector: direction and length written as (x, y)
- Dot product: the sum of products of components