Cartesian to polar converter
Turn x and y into polar form: the point (3, 4) sits 5 units from the origin at an angle of 0.927295218002 radians. The angle always lands in the correct quadrant, and a negative angle means the point is below the axis. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- X
- 3
- Y
- 4
- Radius
- 5
- Angle
- 0.927295218
- Angle unit
- rad
The Cartesian to polar coordinates converter takes a point given by its horizontal coordinate x and vertical coordinate y and returns the same point in polar form: the radius, which is the straight-line distance from the origin, and the angle in radians measured counterclockwise from the positive x axis. The angle is computed with the two-argument arctangent, so it always lands in the correct quadrant, and negative angles tell you the point sits below the axis. Both inputs must be finite numbers; anything else is rejected with a clear validation error.
From x and y to radius and angle
Cartesian coordinates locate a point by walking along two perpendicular axes: x steps to the right and y steps up. Polar coordinates locate the very same point differently, by saying how far it is from the origin and in which direction. The distance is the radius, computed as the hypotenuse of the right triangle that x and y form, so for the point (3, 4) the radius is exactly 5.
The direction is the angle, measured in radians counterclockwise from the positive x axis, so a point on the positive y axis sits at an angle of π/2, about 1.5708. Sending the two coordinates to this cartesian to polar coordinates converter returns both values in a single call, with no intermediate steps for you to wire together.
Because the radius comes from a hypotenuse calculation rather than a naive square root of summed squares, the result stays accurate and avoids overflow even when the coordinates themselves are very large finite numbers, which matters in scientific and engineering pipelines where coordinates routinely reach into the millions.
Why the angle uses atan2 and lives in radians
A plain arctangent of y divided by x cannot tell a point in the first quadrant from one in the third, because the ratio is identical, and it breaks entirely when x is zero. The two-argument arctangent, atan2, looks at the signs of both coordinates, so the angle it returns always points into the correct quadrant and is defined for every point except the exact origin.
The result lies in the open-closed interval from negative π to positive π: positive values mean the point is above the x axis, negative values mean below, exactly π means due left, and zero means due right. The origin is a special case: its radius is zero and its angle is undefined mathematically, so this converter returns an angle of zero by convention rather than failing, which keeps pipelines total and predictable while still documenting the choice.
Validation, determinism, and where it fits
Each coordinate must be a finite number. Results are rounded to twelve decimal places so that comparisons stay stable across machines and JavaScript engines. Typical callers are robotics and game code converting joystick or sensor vectors into heading and magnitude, physics tooling that prefers polar form for rotational problems, and data visualisation jobs that place points on radial charts.
What you can do with it
Heading and distance for robotics
Turn a joystick or sensor vector (x, y) into a magnitude and a heading angle in radians that motor controllers and path planners consume directly.
Physics and engineering math
Move a vector into polar form to separate magnitude from direction before applying rotational or wave equations.
Radial charts and visualisation
Convert data points into radius and angle so they can be placed on polar plots, radars, and circular heatmaps.
FAQ
What does it cost?
The same conversion is free to run in your browser on this page.
What exactly is returned?
The radius (distance from the origin), the angle in radians in the interval (-π, π], the unit marker "rad", and the echoed x and y inputs.
Why radians and not degrees?
Radians are what trigonometric functions in every major language accept, so the result feeds the next computation without conversion. Multiply by 180/π if you need degrees.
What happens at the origin (0, 0)?
The radius is 0 and the angle is mathematically undefined, so the converter returns an angle of 0 by convention instead of failing.
Which inputs are rejected?
Anything that is not a finite number: missing fields, null, booleans, arrays, empty or non-numeric strings, NaN, and Infinity. Numeric strings like "3.5" are accepted.
Is the angle always in the correct quadrant?
Yes. It is computed with the two-argument arctangent atan2(y, x), which uses the signs of both coordinates to place the angle in the right quadrant.
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/math/cartesian-to-polar \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x":3,"y":4}'const res = await fetch("https://api.kit.forhosting.com/math/cartesian-to-polar", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x": 3,
"y": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/cartesian-to-polar",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x": 3,
"y": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/cartesian-to-polar", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x":3,"y":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x":3,"y":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/cartesian-to-polar", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"x": 3,
"y": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.cartesian_to_polar",
"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
The same conversion runs free in your browser on this page, and the identical code serves the paid API at $0.002 per request.
Why the angle uses atan2 and lives in radians
Radians are the natural unit for this API because every programming language's trigonometric functions consume radians directly, so the answer can feed straight into sine, cosine, or a rotation matrix without a conversion step.
Validation, determinism, and where it fits
The endpoint accepts JSON numbers and numeric strings such as "3.5" or "-2", which is convenient when values arrive as form fields, but it rejects nulls, empty strings, booleans, arrays, the text NaN, and anything infinite, answering with an invalid input error that names the offending field instead of silently producing a meaningless angle. It runs on the edge in milliseconds, keeps nothing after the response, and costs $0.002 per request through the API while remaining free to use interactively in the browser.