ForHosting KIT · Math

Vector projection calculator

Projecting (3, 4) onto (1, 0) gives a scalar projection of 3, the vector (3, 0) and a perpendicular leftover of (0, 4). Use it to split a force along a cable or check a residual. 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
First text
3, 4
Second text
1, 0
You get
Scalar projection
3
Vector projection
3, 0
Orthogonal
0, 4
Dot
3

Vector projection answers a basic linear-algebra question: how much of one vector points along another, and what vector is that parallel piece? Given a source vector a and a non-zero target b, the scalar projection is the signed length of a along the unit direction of b, and the vector projection is the unique multiple of b that is closest to a in Euclidean distance. Those two numbers and that parallel vector appear in work-and-force problems, shadow lengths, least-squares residuals, graphics lighting, and every course that builds orthonormal bases.

What scalar and vector projection mean

Fix a non-zero target vector b in R to the power of n. The unit vector in the direction of b is b divided by its Euclidean norm. The vector projection multiplies that signed length by the unit direction, or equivalently multiplies b by the ratio of a dot b over b dot b.

The result always lies on the line spanned by b and is the closest point on that line to a. The difference a minus the projection vector is orthogonal to b; that residual is the part of a that cannot be explained by a multiple of the target. These identities hold in every dimension greater than or equal to one, as long as both vectors share the same number of components and b is not the zero vector.

Classroom examples often use two-dimensional pairs such as a equals three four and b equals one zero, where the projection lands cleanly on the first axis; the same formulas apply without change to three-dimensional forces or higher-dimensional feature vectors. Understanding the signed scalar first makes the vector formula mechanical: scale the unit direction by that scalar, or scale b by the ratio of the two dots.

Practical use, pricing, limits, and delivery

Use the browser tool when you want an immediate scalar and vector projection while checking homework, preparing a lecture slide, resolving a force into components along a cable, or debugging a residual that should be orthogonal to a design direction. There is no language model, no external linear-algebra service, and no randomness, so the capability is safe to pin in continuous-integration checks and reproducible lesson materials. Results are fully deterministic: the same a and b always yield the same scalar, vector, and residual.

Prefer this tool when the geometric story is projection onto a single direction; for multi-vector subspaces, least-squares onto a matrix columns span, or cross products, use a different capability. Keep components within ordinary floating-range magnitudes so intermediate overflow is not a concern; for classroom integers and typical engineering scales the solver is exact within double precision. Source inputs and outputs follow the same retention rules as other KIT parse items, and a failed task is never charged after validation.

Homework and tutoring verification

Students and graders confirm scalar and vector projections for equal-length pairs, including clear failures when the onto vector is zero or dimensions differ, without a local CAS install.

Force and work component checks

Lab scripts that resolve a force along a cable or compute work-related parallel pieces call a deterministic projection oracle instead of reimplementing norm and zero checks in every language.

What happens if the target vector is the zero vector?

Projection is undefined when the onto vector has zero length.

What if a and b have different lengths?

Projection requires equal dimension; there is no silent padding.

Is the vector projection calculator free?

The browser tool runs free on your device.

Does this project onto a plane or multi-vector subspace?

No. This capacity projects onto a single non-zero direction b. Multi-vector subspace projections need a different capability or library.

How do I project (3, 4) onto (1, 0)?

Divide the dot product of the two vectors by the length of the target; here that gives a scalar projection of 3. Multiply it by the target's direction to get the vector projection (3, 0); the leftover (0, 4) is perpendicular.

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/algebra/vector-projection

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/algebra/vector-projection \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":[3,4],"b":[1,0]}'
{
  "a": [
    3,
    4
  ],
  "b": [
    1,
    0
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "algebra.vector_projection",
  "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.

This capability takes two equal-length numeric vectors, rejects a zero onto-vector and mismatched dimensions with invalid_input, and returns the scalar projection, the projection vector, the orthogonal residual, the raw dot product, and the target norm.

What scalar and vector projection mean

The scalar projection of a onto b is the ordinary dot product of a with that unit vector: it is positive when a and b form an acute angle, negative when the angle is obtuse, and zero when they are orthogonal. If b is zero, division by the norm is undefined, so this calculator refuses the request instead of emitting NaN.

How to call the calculator and read the response

Each is a non-empty array of finite numbers of equal length. Near-zero float dust is cleaned so goldens and demos stay stable while ordinary non-integer reals keep full double precision. Send a JSON body with required fields a and b. You may use aliases vector, u, or source for a, and onto, v, or target for b; JSON strings of the same arrays are also accepted when a client serializes nested data as text. The engine rejects missing fields, empty arrays, non-numeric components, Infinity or NaN cells, and unequal lengths with invalid_input, and those failures are not charged. When b parses cleanly but every component is zero, the request also fails with a clear message that the target vector is the zero vector and projection is undefined. On success the response includes scalar_projection (signed length along unit b), vector_projection (the parallel component as an array), orthogonal (a minus that projection), dot (a·b), onto_norm (the Euclidean length of b), dimension, and echo fields a and b with the parsed numeric vectors. Wire the endpoint into scripts that already speak JSON and need a stable contract rather than reimplementing zero checks and dimension rules in every language.

Practical use, pricing, limits, and delivery

Each successful request is one billable item at $0.002; failed validation, dimension mismatches, and zero-target rejections do not consume balance.

Residual and graphics pipelines

Graphics and numerical tools that split a vector into parallel and perpendicular parts against a light or view direction get stable JSON for both the projection and the orthogonal residual.

How do I project vector a onto vector b with this API?

Send JSON with a and b as equal-length arrays of finite numbers. The response returns scalar_projection, vector_projection, orthogonal residual, dot, onto_norm, and dimension.

Read the full KIT documentation →