ForHosting KIT · Math

Equation of a circle from diameter endpoints

The ends (1, 2) and (5, 6) give a circle centred at (3, 4) with radius squared 8, so its equation is (x − 3)² + (y − 4)² = 8. Enter both ends of any diameter and get the whole circle at once. 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
X1
1
Y1
2
X2
5
Y2
6
Precision
6
You get
Center x
3
Center y
4
Radius
2.828427
Diameter
5.656854

Send four numbers, get back the full circle in one call.

Why two ends of a diameter are enough

Three arbitrary points are needed to pin down a circle, but the two ends of a diameter carry more information than that. The center is exactly halfway between them, so you take the average of the two x values and of the two y values. The radius is half the distance between the ends. With (1, 2) and (5, 6), the center is (3, 4), the diameter is about 5.656854 and the radius about 2.828427, whose square is exactly 8. There is no perpendicular bisector to draw and no special case where the points line up: two different ends always define one circle.

Standard or general form, and the usual slips

The standard form, (x − 3)² + (y − 4)² = 8 in the example, keeps the center and the radius visible, which is what you want for plotting, for checking whether a point lies on the circle or for comparing against a drawing. Expanding the brackets gives the general form, x² + y² − 6x − 8y + 17 = 0. Remember that the right-hand side of the standard form is the radius squared, not the radius, and that a center at 3 shows up as x − 3. When the center sits on an axis, the empty terms are left out rather than printed as zero. You choose how many decimals the numbers keep.

Reading the standard and general forms

The standard form (x − h)² + (y − k)² = r² keeps the geometry visible: h and k are the center, and the right-hand side is the radius squared. It is the form you want when plotting, checking whether a point lies on the circle, or comparing against a drawing.

Note the convention for degenerate coordinates: when the center lies on an axis or at the origin, terms that vanish are omitted from the strings rather than printed as zero coefficients, so the equation you paste into a document looks the way a mathematician would write it.

Reconstruct a circle in CAD or metrology

Turn two probed points on opposite sides of a bore or shaft into the full circle equation for a fit report or drawing.

Feed a geometry pipeline

Compute the circle once, then pass the numeric center and radius — not parsed strings — into intersection, area or distance steps downstream.

What input does it expect?

Numbers or numeric strings both work, and an optional precision field sets the decimal places of the response.

Is any data stored?

No. The computation is pure arithmetic; the coordinates are processed and discarded, and only the result is returned.

How do I find the center of a circle from the ends of a diameter?

Average the two x values and the two y values. The center is the midpoint of the diameter, so the ends (1, 2) and (5, 6) give a center at (3, 4).

How do I get the radius from the two ends of the diameter?

Measure the distance between the two ends and halve it. For (1, 2) and (5, 6) the diameter is about 5.656854 and the radius about 2.828427, so the radius squared is exactly 8.

Why are some terms missing from the equation?

When the center lies on an axis or at the origin, the terms that vanish are left out instead of being written with a zero, so the equation reads the way you would write it by hand.

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/math/equation-circle-diameter-endpoints

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/math/equation-circle-diameter-endpoints \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x1":1,"y1":2,"x2":5,"y2":6}'
{
  "x1": 1,
  "y1": 2,
  "x2": 5,
  "y2": 6
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.equation_circle_diameter_endpoints",
  "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_diameter1e-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.

The circle-from-diameter API takes the coordinates of the two endpoints of a diameter and returns everything about the circle that segment defines: the center as the midpoint, the radius as half the distance between the endpoints, and the equation of the circle in both standard form (x − h)² + (y − k)² = r² and general form x² + y² + Dx + Ey + F = 0. It is a closed-form computation, not an iterative fit, so the same four coordinates always produce the same answer, rounded to the precision you choose.

Why a diameter is all you need

A circle is fully determined by three arbitrary points, but when the two points you hold are the ends of a diameter you need far less machinery. The center is exactly the midpoint of the segment — the average of the two x-coordinates and of the two y-coordinates — and the radius is exactly half the length of the segment, which the distance formula gives in one pass. You send x1, y1, x2 and y2 as numbers or numeric strings, and you receive the center coordinates, the radius, the diameter, the squared radius and the equation strings in standard and general form. There is no determinant to evaluate, no perpendicular bisector to intersect and no collinearity case to worry about: two distinct endpoints always define one valid circle. This endpoint computes that circle directly.

Reading the standard and general forms

The general form x² + y² + Dx + Ey + F = 0 expands the binomials and collects the constants, with D = −2h, E = −2k and F = h² + k² − r². That is the form many solvers, algebraic systems and printed textbooks prefer, because the coefficients drop straight into further manipulation. This capability returns both, formatted as readable strings with the precision you selected, plus the numeric values so you never have to parse the strings to get the center or radius back out.

Validation, limits and honest errors

Every coordinate must be a finite number. Coordinates are bounded to an absolute value of 10^12, which keeps the squared magnitudes well inside double precision. The optional precision parameter sets the decimal places of every rounded number in the response and accepts integers from 0 to 15, defaulting to 10. NaN, Infinity, booleans, objects and non-numeric strings are rejected with an invalid_input error that names the offending field, and the request is never charged, so a pipeline can surface the problem instead of propagating a nonsense circle downstream. If the two endpoints coincide — or sit closer together than 10^−15 — no diameter exists and the request fails with a message saying exactly that, rather than returning a circle of zero radius that would divide by zero the moment you used it. Pricing is flat: $0.002 per request, one item per call, whatever the magnitude of your coordinates. The same module that runs here runs free in your browser, so you can verify a worked example by hand before wiring the endpoint into production.

Check homework and textbook answers

Verify the center, radius and standard-form equation for a diameter-endpoints exercise without reworking the algebra by hand.

What does it cost?

$0.002 per request, one item per call. It is also free to run in your browser on this page with the same code.

What happens if a coordinate is not a finite number?

The request fails with an invalid_input error naming the field — NaN, Infinity and non-numeric strings are all rejected — and the request is not charged.

What if the two endpoints are the same point?

A diameter needs two distinct points, so the request fails with an invalid_input error instead of returning a circle of zero radius.

Which equation forms are returned?

Both: the standard form (x − h)² + (y − k)² = r² and the general form x² + y² + Dx + Ey + F = 0, plus the numeric center, radius, diameter and squared radius.

Read the full KIT documentation →