Foot of perpendicular calculator
Find the point on a line closest to a given point: a perpendicular dropped from the origin onto the line 3x + 4y − 5 = 0 lands at (0.6, 0.8), at distance 1. You also see whether the point already lies on the line. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- A
- 3
- B
- 4
- C
- -5
- X
- 0
- Y
- 0
- Foot x
- 0.6
- Foot y
- 0.8
- Distance
- 1
- Denom
- 25
The foot of the perpendicular is the unique point on an infinite line that is closest to a given external point. Surveyors use it when they project a landmark onto a property edge, students need it when a textbook asks for the coordinates of the projection of a point onto a line written as ax plus by plus c equals zero, CAD and game engines need the foot when snapping a vertex or character to a wall constraint, and robotics path planners use it when they constrain an end-effector to a linear guide. This capability accepts the five numbers a, b, c, x, and y, rejects the degenerate case where a and b are both zero because that equation is not a line, and returns the foot coordinates together with the perpendicular distance and a flag that is true when the point already lies on the line.
What the foot 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 squared length of that normal is the denominator a squared plus b squared.
For a query point (x, y), form the residual r equals a times x plus b times y plus c. The foot of the perpendicular is obtained by moving from the query point along the unit normal by the signed distance r over the normal length. When the residual is zero, the point already satisfies the line equation, the foot coincides with the point, 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 minus five, denom twenty-five, foot at (three-fifths, four-fifths), distance one. Every step is elementary arithmetic and one square root for the optional distance field, so there is no iteration, no sampling, no dependence on wall-clock time, and no need for slope or intercept in the input contract.
What you can do with it
Project a landmark onto a survey or property edge
Drop a perpendicular from a measured point onto a boundary line in general form and record the foot as the official projection on the edge.
Snap a vertex or agent to a wall constraint
In CAD, games, or robotics, move a point onto the nearest location on an infinite linear constraint by computing the foot of the perpendicular.
FAQ
What is the foot of the perpendicular formula?
The foot lies on the line and the segment from the point to the foot is perpendicular to the line.
What if the point already lies on the line?
No special case is required beyond the same formula.
Is this the same as point-to-line distance?
Related but different intent. Distance returns only the length of the perpendicular. This capability returns the foot coordinates (and includes distance as a convenience field).
Is the foot of perpendicular calculator free?
The browser tool is free and runs locally.
Why is a line with a and b both zero rejected?
With both coefficients at zero the equation shrinks to the constant c and describes no line at all. Instead of inventing coordinates, the tool asks you to correct the coefficients first.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geom/foot-of-perpendicular \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":3,"b":4,"c":-5,"x":0,"y":0}'const res = await fetch("https://api.kit.forhosting.com/geom/foot-of-perpendicular", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": 3,
"b": 4,
"c": -5,
"x": 0,
"y": 0
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/foot-of-perpendicular",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": 3,
"b": 4,
"c": -5,
"x": 0,
"y": 0
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/foot-of-perpendicular", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":3,"b":4,"c":-5,"x":0,"y":0}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":3,"b":4,"c":-5,"x":0,"y":0}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/foot-of-perpendicular", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"a": 3,
"b": 4,
"c": -5,
"x": 0,
"y": 0
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.foot_of_perpendicular",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Results are deterministic JSON with fixed decimal rounding—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 foot formula is and how the numbers work
In closed form that is foot_x equals x minus a times r over denom and foot_y equals y minus b times r over denom. 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 coordinates. Another check is any point known to lie on the line: foot must equal the point and on_line must be true.
How to call the API and what comes back
Use it from geometry homework pipelines, construction projection scripts, game-level snap tooling, interview-prep sandboxes, GIS orthographic drop checks, or any workflow that needs a reproducible foot of the perpendicular 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 external 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 foot_x and foot_y (the coordinates of the perpendicular foot on the line), distance (non-negative perpendicular length from the point to the foot), on_line (true when the residual is zero), denom (a squared plus b squared), method set to foot_of_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.
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). Prefer this capability when you already have the general form of an infinite line and need the foot point itself rather than only the distance. 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. When teaching, prefer paired examples: three-four-minus-five at the origin for foot (0.6, 0.8) and distance one; a point on the line for coinciding foot and on_line true; and a equals b equals zero to demonstrate the hard rejection path that protects callers from a non-line. Because the formula only needs five scalars, students can recompute residual, denom, and the two foot coordinates by hand for small integers and match the API line by line. This landing targets people searching for a foot of perpendicular calculator or the coordinates of the projection of a point onto ax plus by plus c equals zero; it is not a segment-projection tool—clamping the foot to a finite segment needs endpoint 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 a times foot_x plus b times foot_y plus c is approximately zero, that distance equals the Euclidean length from (x, y) to (foot_x, foot_y), and that on_line is true exactly when distance is zero.
Integration use cases
Homework and exam checks for the foot of a perpendicular
Give students a line ax+by+c=0 and a point; compare their hand-computed foot coordinates against a deterministic API or free browser result.
Technical questions
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 inventing foot coordinates.