Relative velocity 2D calculator
A body moving at (10, 0) seen from one moving at (3, 4) has a relative velocity of (7, −4): 7 along the horizontal and 4 downward. Enter both velocities as components and get the relative speed and its direction. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- V1x
- 10
- V1y
- 0
- V2x
- 3
- V2y
- 4
- Relative vx
- 7
- Relative vy
- -4
- Magnitude
- 8.0622577483
- Direction deg
- -29.7448812969
Relative velocity in the plane is the vector difference between two velocity vectors expressed in the same reference frame. There is no network call, no random sampling, and no date-dependent shortcut—only deterministic vector arithmetic suitable for CI goldens and classroom keys.
What relative velocity tells you
Relative velocity answers a simple question: how does one moving object look from another moving object? The velocity of A relative to B is what an observer riding with B would measure for A. It appears in textbook river-boat problems, in two cars approaching each other and in airplane wind triangles, and lab courses use it to turn the measured speeds of two carts into an approach speed for collision timing. When both velocities are written as horizontal and vertical components in the same frame, the calculation is a subtraction: the first velocity minus the second, part by part. With a first body at (10, 0) and a second at (3, 4), the relative velocity is (7, −4). Its length gives the relative speed, and its angle gives the heading.
Mistakes that spoil the result
The most common mistake is mixing reference frames: both velocities must be measured against the same ground, river bank or air, otherwise the difference means nothing. The four components must also share one unit, such as metres per second. Order matters, because the result is the first velocity minus the second; swapping them gives B as seen from A instead. Finally, check the angle convention: the direction is measured counterclockwise from the positive horizontal axis, so a negative angle points below it. The calculator gives degrees and radians, so you can copy whichever your worksheet uses without converting by hand.
Where a relative velocity 2D calculator earns its keep
Students meet relative velocity when river-boat problems, two-car approach speeds, and airplane wind triangles appear in textbooks; this page turns those component lists into magnitude and heading without graphing paper. Lab courses that track two carts with ultrasonic sensors can feed measured velocities into the same contract and log relative approach speed for collision timing. First-order engineering checks use the relative vector when two platforms report body-frame velocities that have already been rotated into a common horizontal plane.
Keep requests small, pin the rounded magnitude and angles in tests, and you get reproducible relative kinematics for homework, LMS plugins, and edge workers without standing up a full physics engine of your own.
What you can do with it
Homework and river-boat problems
Subtract given Cartesian velocity components to obtain closing speed and heading for two-body relative motion exercises.
Lab carts and sensor pipelines
Convert paired cart velocities into relative approach speed for collision timing, plots, and tutoring software.
FAQ
What happens if a component is non-numeric?
Non-finite values, empty strings, and non-numeric tokens are rejected and are not billed.
Can both velocities be zero or equal?
Yes. Equal velocities yield magnitude zero and direction zero. Zero vectors are valid finite inputs.
How do I calculate relative velocity in two dimensions?
Subtract the second velocity from the first, component by component: horizontal minus horizontal and vertical minus vertical. The relative speed is the length of that difference, found with Pythagoras, and the direction is its angle.
What does the velocity of A relative to B mean?
It is the velocity that an observer riding along with B would see for A. If both move in exactly the same way, A appears to stand still and the relative velocity is zero.
From where is the direction angle measured?
From the positive horizontal axis, turning counterclockwise, and it is given both in degrees and in radians. A negative angle means the relative velocity points below that axis, turning clockwise.
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/mech/relative-velocity-2d \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"v1x":10,"v1y":0,"v2x":3,"v2y":4}'const res = await fetch("https://api.kit.forhosting.com/mech/relative-velocity-2d", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"v1x": 10,
"v1y": 0,
"v2x": 3,
"v2y": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/mech/relative-velocity-2d",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"v1x": 10,
"v1y": 0,
"v2x": 3,
"v2y": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/mech/relative-velocity-2d", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"v1x":10,"v1y":0,"v2x":3,"v2y":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"v1x":10,"v1y":0,"v2x":3,"v2y":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/mech/relative-velocity-2d", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"v1x": 10,
"v1y": 0,
"v2x": 3,
"v2y": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "mech.relative_velocity_2d",
"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
Given the Cartesian components of body 1 and body 2, this relative velocity 2D calculator forms v_rel equals v1 minus v2, then reports the relative components, the Euclidean magnitude, and the polar direction from the positive x-axis using atan2. Every component must be a finite number; non-numeric values fail with invalid_input and are not billed.
What 2D relative velocity means and what the response contains
In introductory mechanics and planar kinematics, the velocity of object A relative to object B is the vector that an observer riding with B would assign to A. The direction is the angle of the relative vector measured counterclockwise from the positive horizontal axis, returned both in radians and in degrees so worksheets that prefer either convention can copy a single field without converting by hand. Zero relative velocity is allowed and yields magnitude zero with direction zero from atan2 of zero and zero, matching common library behavior. When both velocities are already resolved into Cartesian components in a shared inertial frame, that relative velocity is simply the component-wise difference: relative_vx equals v1x minus v2x and relative_vy equals v1y minus v2y. The magnitude of that difference is the Euclidean length sqrt of relative_vx squared plus relative_vy squared, which is the speed at which A approaches or recedes from B along the connecting relative path when positions are also known. This endpoint does not integrate trajectories, does not apply Coriolis corrections, and does not change frames that are rotating; it answers only the static vector difference of two finite planar velocities. The success payload echoes the four input components after stable rounding, then exposes relative_vx, relative_vy, magnitude, direction_deg, direction_rad, a short formula string, a method tag vector_difference_2d, and a unit hint that any consistent length-over-time unit may be used when inputs share that unit. Pair this tool with velocity-components helpers when you only know speed and angle, or with collision endpoints when you need final velocities after an impact rather than the pre-impact relative vector alone.
Input contract, numeric validation, and error behaviour
Magnitudes above the documented absolute ceiling are rejected to keep intermediate products finite. Failed validation is not charged. Keep units consistent yourself: the calculator does not convert kilometres per hour into metres per second; it only subtracts numbers you already expressed in one coherent system. POST a JSON object with four required fields: v1x and v1y for the first velocity, and v2x and v2y for the second. Each field may be a JSON number or a decimal numeric string, including optional leading signs and scientific notation that parse as finite values. Preferred names are the canonical DOM-safe identifiers; aliases vx1, vy1, vx2, vy2 and u_x, u_y, w_x, w_y are accepted so spreadsheets and typed forms can reuse common textbook symbols without renaming columns. Missing fields, empty strings, NaN, Infinity, and non-numeric tokens such as letters or mixed units fail with invalid_input and a message that names the offending field, so a bad cell never becomes a silent zero. The free browser path and the paid API path share the same pure module, which means a worksheet example you verify on this page will match an automated pipeline that posts the same four numbers at $0.002 per successful item.
Where a relative velocity 2D calculator earns its keep
Teachers pre-generate answer keys for modest component sets and reject non-numeric student paste with a clear invalid_input signal instead of a mysterious empty chart. Product and education tools call the endpoint when a learner types four boxes and the UI must show metres per second of closing speed plus a direction badge.
Integration use cases
Deterministic physics test fixtures
Generate reproducible relative_vx, relative_vy, magnitude, and direction fields for game-physics CI and interception demos.
Technical questions
How is relative velocity defined here?
Relative velocity of body 1 with respect to body 2 is v_rel = v1 − v2 using the four Cartesian components you supply. Magnitude is √(relative_vx² + relative_vy²); direction is atan2(relative_vy, relative_vx).
Which angle convention is used?
Direction is measured counterclockwise from the positive x-axis via atan2(vy, vx), returned as direction_rad and direction_deg. All four quadrants are covered.
What does the relative velocity 2D calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.