ForHosting KIT · Math

Point to line distance

The origin lies exactly 1 unit from the line 3x + 4y − 5 = 0. Enter the line's three coefficients and a point to get the shortest distance, its sign and whether the point sits on the line, for clearances, walls or homework. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
3
B
4
C
-5
X-coordinate of the point
0
Y-coordinate of the point
0
You get
Distance
1
Signed distance
-1
Norm
5

The perpendicular distance from a point to a line is the shortest path from that point to any location on the infinite line. You need it when a surveyor checks clearance from a parcel boundary, a student verifies homework on the general line equation, a game or CAD pipeline measures offset from a wall defined by ax plus by plus c equals zero, or a robotics path planner keeps an end-effector clear of a linear constraint. This capability accepts the five numbers a, b, c, x, and y, rejects the degenerate case where a and b are both zero (that equation is not a line), and returns the non-negative distance together with the signed distance, the normal length, and whether the point already lies on the line.

What the formula is and how the numbers work

Write the infinite line in general (Cartesian) form as a times x plus b times y plus c equals zero. The pair (a, b) is a normal vector to the line: it points perpendicular to every direction that stays on the line. The length of that normal is the Euclidean norm sqrt of a squared plus b squared.

For a query point (x, y), plug the coordinates into the left-hand side to get the residual a times x plus b times y plus c. The absolute value of that residual divided by the normal length is exactly the perpendicular distance from the point to the line. When the residual is zero, the point satisfies the line equation and the distance is zero.

A classic sanity check is the line three x plus four y minus five equals zero (a 3-4-5 normal) and the origin: residual absolute value five, norm five, distance one. Every step is elementary arithmetic and one square root (or hypot), so there is no iteration, no sampling, no dependence on wall-clock time, and no need for slope or intercept in the input contract.

Clearance and setback from a linear boundary

Measure how far a structure, path, or sensor reading sits from a survey line, wall, or property edge expressed in general form.

Game, CAD, and robotics offset from a wall constraint

Compute lateral offset of a character, mesh vertex, or end-effector from an infinite plane line used as a collision or guidance constraint.

What is signed distance?

Signed distance is (ax+by+c)/sqrt(a²+b²). Its sign tells which half-plane the point is in relative to the oriented normal (a,b); magnitude matches the ordinary distance.

Does this work for a line segment?

No. This capability measures distance to the infinite line.

Is the point to line distance calculator free?

The browser tool is free and runs locally.

What if the first two coefficients are both zero?

Then the expression is just a constant and describes no line at all. The calculator rejects it instead of inventing a distance, so check that at least one of the first two coefficients is not zero.

How can I tell if a point lies on the line?

Its distance comes out as zero and the result marks it as on the line. That happens exactly when the coordinates satisfy the line equation, a handy check for points you believe sit on a boundary.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/geom/point-line-distance

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/geom/point-line-distance \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":3,"b":4,"c":-5,"x":0,"y":0}'
{
  "a": 3,
  "b": 4,
  "c": -5,
  "x": 0,
  "y": 0
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "geom.point_line_distance",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_abs1000000000000
min_norm1e-15
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Results are deterministic JSON—no computer-algebra system, no random seeds, and the same pure solve function in the free browser tool and the prepaid API path—so homework checks, grading scripts, and production pipelines all see the same numbers every time.

What the formula is and how the numbers work

When a and b are both zero, the expression collapses to a constant c and does not define a line at all—this tool returns invalid_input instead of inventing a distance. Another check is any point known to lie on the line: distance must be zero and on_line true.

How to call the API and what comes back

Use it from geometry homework pipelines, construction clearance scripts, game-level tooling, interview-prep sandboxes, GIS offset checks, or any workflow that needs a reproducible point-to-line distance without installing a computer-algebra package on every machine. Send a JSON body with five numeric fields. Field a is the first coefficient of the line; aliases A and coeff_a are accepted. Field b is the second coefficient; aliases B and coeff_b map to the same meaning. Field c is the constant term; aliases C and coeff_c are accepted. Field x is the point's horizontal coordinate; aliases x0, px, and point_x work. Field y is the vertical coordinate; aliases y0, py, and point_y work. On success the response echoes a, b, c, x, and y, adds distance (non-negative), signed_distance (positive or negative according to which side of the oriented normal the point sits on), on_line (true when distance is zero), norm (sqrt of a squared plus b squared), method set to perpendicular, and a short formula block documenting the closed forms. Failed validation—missing a required field, a non-finite number, a value outside published absolute limits, or a pair a and b that are both zero—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.

Practical tips, limits, and related searches

If your line is given by two points (x1, y1) and (x2, y2), convert first: a equals y1 minus y2, b equals x2 minus x1, c equals x1 times y2 minus x2 times y1 (or any non-zero multiple). When teaching, prefer paired examples: three-four-minus-five at the origin for distance one; a point on the line for distance zero; and a equals b equals zero to demonstrate the hard rejection path that protects callers from a non-line. Prefer this capability when you already have the general form of an infinite line. Keep coefficients and coordinates inside the published absolute range up to one trillion so intermediate products stay finite in IEEE double precision on the Worker and in the browser. Units are whatever you pass—metres, feet, or game units—as long as a, b, c, x, and y are consistent with a single length unit for the distance result; the API does not convert units for you. Because the formula only needs five scalars, students can recompute the residual and the hypot by hand for small integers and match the API line by line. This landing targets people searching for a point to line distance calculator or perpendicular distance to ax plus by plus c equals zero; it is not a segment-distance tool—shortest distance to a finite segment needs clamp logic that is out of scope here. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when users type a vanishing normal while learning the contract. Round-trip checks are easy: after solving, confirm that distance equals the absolute value of signed_distance, that on_line is true exactly when distance is zero, and that norm squared equals a squared plus b squared within floating tolerance.

Homework and exam checks for point-line distance

Give students a line ax+by+c=0 and a point; compare their hand-computed perpendicular distance against a deterministic API or free browser result.

What is the point to line distance formula?

For the line ax+by+c=0 and point (x,y), the perpendicular distance is |ax+by+c| / sqrt(a²+b²). The absolute value ensures a non-negative length.

Why are a and b both zero rejected?

If a=b=0 the equation reduces to c=0 or a contradiction and does not define a line. This tool returns invalid_input instead of a meaningless distance.

Read the full KIT documentation →