Unit vector to latitude and longitude
Turn a Cartesian direction on the unit sphere into geographic coordinates that people and mapping software can read.
Run — free
Supply the x, y, and z components of a right-handed unit vector, and this converter returns latitude and longitude in degrees with a selectable display precision. It validates that the vector really has unit length, tolerates only tiny floating-point drift, and uses a documented axis convention. The calculation is deterministic, needs no network or geocoding database, and costs $0.002 per successful API request.
Understand the axis convention before converting
A point on a unit sphere can be stored as three Cartesian components instead of two angles. This capability uses the common right-handed Earth-centered convention: positive x points to latitude zero and longitude zero, positive y points to latitude zero and longitude ninety degrees east, and positive z points to the north pole. Consequently, the vector (1, 0, 0) becomes zero degrees latitude and zero degrees longitude, while (0, 1, 0) becomes zero degrees latitude and ninety degrees east. A negative y component places the result west of the prime meridian, and a negative z component places it in the southern hemisphere. The returned longitude follows the conventional range from negative one hundred eighty through positive one hundred eighty degrees. At either pole, longitude is mathematically indeterminate because every meridian meets there; the calculation still returns the stable value produced by atan2 from the supplied x and y components. Make sure vectors from graphics, astronomy, robotics, or simulation software use this same axis order before interpreting the result as a geographic coordinate. Some systems swap y and z or reverse an axis, and those conventions describe a different orientation even when the three numbers still have unit length. This tool converts coordinates; it does not infer or repair an undocumented source coordinate system.
How validation and spherical conversion work
The converter first checks that x, y, and z are finite JSON numbers between negative one and positive one. It then calculates their Euclidean magnitude with the three-component hypotenuse operation. A true unit vector has magnitude one, but real pipelines often produce harmless floating-point drift after matrix multiplication or serialization. For that reason, magnitudes within one millionth of one are accepted and normalized before the angles are calculated. Larger deviations are rejected as invalid input instead of silently projecting an arbitrary non-unit vector onto the sphere. Latitude is the inverse sine of normalized z. Longitude is atan2 of normalized y and normalized x, which preserves the correct quadrant and works across the antimeridian without a manual sign rule. Both angles are converted from radians to degrees and rounded to the requested precision, ten decimal places by default and zero through fifteen when explicitly selected. Negative zero is collapsed to ordinary zero so JSON responses and test fixtures stay clean. The response includes descriptive latitude and longitude fields, compact lat and lon aliases, the applied precision, and a convention tag. No network, randomness, clock, datum lookup, or iterative approximation is involved, so identical input produces identical output in the browser and API. The method describes directions on an ideal unit sphere and does not calculate altitude, Earth ellipsoid height, or a street address.
Use the result safely in maps and data pipelines
Unit vectors are useful because they avoid longitude wrap discontinuities, interpolate directions cleanly, and fit naturally into three-dimensional engines. Human-facing interfaces, GIS exports, logs, and map labels usually need latitude and longitude instead. This converter provides the boundary between those representations. It can turn a camera ray or globe-picking result into a readable coordinate, decode normalized positions stored in a simulation dataset, or create transparent test fixtures for spherical geometry code. Validate the source meaning as well as its magnitude: a normalized surface normal and an Earth-centered position can have the same numeric shape but represent different things. If a source vector has an arbitrary length, normalize it deliberately in the producing system and record that choice rather than relying on this endpoint to hide the discrepancy. The strict unit-length check is intended to expose wrong units, missing normalization, and damaged records early. Results are angular directions only; they do not include altitude, terrain elevation, geodetic datum conversion, or reverse-geocoded place names. For batch work, call the capability once per item and preserve enough decimal precision for the downstream task. Ten decimal places are convenient for reproducible technical output, while fewer places are easier to display. Interactive calculations can run locally in the browser, and automated requests use the same deterministic solver for $0.002 per successful request, keeping manual checks and production pipelines aligned.
What you can do with it
Label a 3D globe selection
Convert a normalized globe-picking direction into latitude and longitude for a tooltip, debug panel, or exported marker.
Decode simulation coordinates
Turn unit-sphere positions from scientific or engineering data into readable angular coordinates with a documented axis convention.
Build spherical geometry fixtures
Generate stable latitude and longitude expectations for tests that store directions as normalized Cartesian vectors.
FAQ
What does a conversion cost?
A successful API request costs $0.002. The same deterministic calculation can run in the browser.
Which formula is used?
Latitude is asin(z) and longitude is atan2(y, x) after the accepted vector is normalized to remove tiny floating-point drift.
Does the vector have to be exactly unit length?
It must be within one millionth of magnitude one. This permits ordinary floating-point drift while rejecting vectors that were not normalized.
What coordinate convention does it expect?
Positive x is latitude 0 and longitude 0, positive y is latitude 0 and longitude 90 east, and positive z is the north pole.
What longitude is returned at a pole?
Longitude is undefined at an exact pole, but the response reports the stable atan2 result from the supplied x and y components.
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/geo/unit-vector-to-latlon \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x":1,"y":0,"z":0}'const res = await fetch("https://api.kit.forhosting.com/geo/unit-vector-to-latlon", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x": 1,
"y": 0,
"z": 0
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geo/unit-vector-to-latlon",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x": 1,
"y": 0,
"z": 0
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geo/unit-vector-to-latlon", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x":1,"y":0,"z":0}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x":1,"y":0,"z":0}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geo/unit-vector-to-latlon", 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": 1,
"y": 0,
"z": 0
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geo.unit_vector_to_latlon",
"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. |