ForHosting KIT · Math

Bearing and heading calculator

From (0, 0) to (1, 1) the bearing is 45°, northeast. Enter the x and y coordinates of a start and a target on a flat grid and get the direction measured clockwise from north, plus the distance between them. 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
X
0
Y
0
X
1
Y
1
You get
Bearing deg
45
Bearing rad
0.7853981634
Distance
1.4142135624
Dx
1

A compass bearing answers a simple spatial question: if you stand at one point on a plane and face another, which way do you look, measured from north and turning clockwise? Surveyors, game developers, robotics students, and outdoor planners all need that number when coordinates are already rectangular—grid eastings and northings, local map meters, or screen-like axes remapped so plus-y is north and plus-x is east. This capacity takes four numbers for the from and to points, rejects the undefined case where both points are identical, and returns the bearing in degrees and radians, the Euclidean distance, the displacement components, and a sixteen-point cardinal label such as N, NE, or WSW.

What compass bearing means on a rectangular plane, and how it differs from pure atan2 slope angles

In navigation and surveying, bearing is the horizontal direction from an observer to a target, measured from true or grid north and increasing clockwise through east, south, and west until it returns to three hundred sixty degrees, which is identified with zero. That convention is deliberately different from the mathematical polar angle that many programming languages return from atan2 of y over x, which starts at the positive x-axis and increases counter-clockwise.

On a rectangular plane where the y-axis points north and the x-axis points east, the navigation form is recovered with atan2 of the easting difference over the northing difference, then normalized into the half-open interval from zero inclusive to three hundred sixty exclusive. Search intent clusters around phrases such as bearing calculator, heading between two points, compass azimuth from coordinates, and direction from point A to B.

People want a numeric heading they can compare to a map rose, a robot odometry frame, or a homework key, not only a slope ratio.

How this calculator validates coordinates, computes bearing and distance, and rejects coincident points

Numeric strings are accepted after trim for convenience when a form posts text. The engine forms dx equals x2 minus x1 and dy equals y2 minus y1. Otherwise the engine takes atan2 of dx and dy, converts to degrees, normalizes into the range from zero to three hundred sixty, derives radians from the normalized degree value, and computes distance with hypot so large components stay numerically stable.

A sixteen-point cardinal label is chosen by rounding the degree bearing to the nearest twenty-two and a half degree sector. Edge cases are explicit: partial inputs, non-numeric text, and the zero-displacement pair all fail before a fake heading is returned.

Practical use, limits, pricing, and delivery channels

Use the browser tool when you want an immediate heading while checking a grid exercise, verifying a robot waypoint list, or confirming that northeast of a base camp really is about forty-five degrees without installing a GIS stack. Accepted inputs are finite rectangular coordinates only: this is not a great-circle bearing on a WGS84 ellipsoid, not a magnetic-declination corrector, and not a path planner that chains multiple legs. Results are fully deterministic: the same four coordinates always yield the same bearing, distance, cardinal, and echoed points.

There is no language model, no external maps service, and no randomness, so the capacity is safe to pin in continuous-integration checks and reproducible lesson materials.

Grid and map homework drills

Students and graders confirm the compass heading and distance between two rectangular points, including clear rejection when the points are the same.

What coordinate convention does the bearing calculator use?

Plus-y is north and plus-x is east. Bearing is measured from north clockwise in degrees on [0, 360).

What happens if the two points are the same?

Compass bearing is undefined when there is no displacement; those calls are not charged.

Is the bearing and heading calculator free?

The browser tool runs free on your device.

Does this compute great-circle bearing from latitude and longitude?

No. It computes planar compass bearing from rectangular coordinates only. Use a geodesy tool for lat/lon great-circle azimuths.

What does the 16-point direction label mean?

It names the nearest of the 16 compass directions, such as N, NE or WSW, so a bearing of 45 degrees reads NE. Treat it as a quick summary; the degree value is the precise figure.

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/trig/bearing

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/trig/bearing \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x1":0,"y1":0,"x2":1,"y2":1}'
{
  "x1": 0,
  "y1": 0,
  "x2": 1,
  "y2": 1
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "trig.bearing",
  "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.

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.

What compass bearing means on a rectangular plane, and how it differs from pure atan2 slope angles

Returning degrees, radians, distance, and a cardinal label in one JSON object makes the result easy to paste into field notes, pin in automated tests, or feed into a larger pipeline without reimplementing degree wrap-around and rose binning in every language you teach or deploy.

How this calculator validates coordinates, computes bearing and distance, and rejects coincident points

Send a JSON body with four finite numbers: x1 and y1 for the starting point, x2 and y2 for the destination. Each field is required; missing values, empty strings, and non-finite quantities fail with invalid_input so incomplete forms never produce a silent zero heading. If both deltas are exactly zero, the two points coincide and compass bearing is undefined because there is no displacement vector; the request fails with invalid_input naming that the points coincide, and those failed calls are not charged. Results are rounded to a stable decimal precision so the same input always yields the same JSON across JavaScript engines.

Practical use, limits, pricing, and delivery channels

Each successful request is one billable item at $0.002; failed validation does not consume balance. Wire the endpoint into survey homework checkers, 2D game navigation demos, contest answer keys that list grid points, robotics notebooks that store local meters, or preprocessing steps where you already prefer an explicit coincident-point error over opaque black-box widgets that cannot show why identical coordinates have no direction.

Robotics and game navigation fixtures

Pipelines that seed unit tests for local-frame headings can call a pure bearing oracle instead of reimplementing atan2 wrap logic in every language.

Field notes and simple route legs

Outdoor planners or sensor logs that already store easting and northing recover a stable degree heading and cardinal label as structured JSON.

How do I compute a compass bearing with this API?

Send x1, y1, x2, and y2 to trig.bearing. The response returns bearing_deg, bearing_rad, distance, dx, dy, cardinal, and the from/to points.

Read the full KIT documentation →