Home › Math › Vector Calculator
Vector Calculator
Computes, for two vectors in 2D or 3D, their magnitudes, dot product, cross product, the angle between them, unit vectors, the scalar and vector projection of the first onto the second, and their sum and difference.
When to use
You have two vectors with numeric components and need any of the standard products, the angle between them, or the projection of one onto the other.
Do not use when: You need the distance between two points rather than vector products (use distance-3d or distance-2d), or the vectors have more than 3 components.
Formula
a·b = Σ aᵢbᵢ; a×b = (a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁); |a| = √(a·a); cos θ = a·b / (|a|·|b|); proj_b a = (a·b / |b|²)·b; scalar projection = a·b / |b|
The angle is evaluated as atan2(|a×b|, a·b), which equals arccos(a·b / (|a|·|b|)) but keeps full precision for nearly parallel or perpendicular vectors; 'parallel' and 'perpendicular' are reported when sin θ or cos θ is below 10^-9.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
vector_a | number_list | yes | Components of the first vector, 2 or 3 numbers (e.g. 1, 2, 3). | |
vector_b | number_list | yes | Components of the second vector, with the same number of components as vector_a. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
dot_product | number | Σ aᵢ·bᵢ; zero when the vectors are perpendicular. | |
cross_product | number_list | [a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁]; 2D vectors are treated as 3D with z = 0, so only the third component can be non-zero. | |
cross_product_magnitude | number | |a|·|b|·sin θ, the area of the parallelogram spanned by a and b. | |
magnitude_a | number | Length of vector a, √(Σ aᵢ²). | |
magnitude_b | number | Length of vector b. | |
angle_degrees | number | ° | arccos(a·b / (|a|·|b|)) in degrees, 0–180. |
angle_radians | number | rad | The same angle in radians. |
unit_vector_a | number_list | a / |a|. | |
unit_vector_b | number_list | b / |b|. | |
scalar_projection | number | a·b / |b| (signed length of a along b). | |
vector_projection | number_list | (a·b / |b|²) · b. | |
sum | number_list | Component-wise sum. | |
difference | number_list | Component-wise difference. | |
relationship | string | 'perpendicular', 'parallel (same direction)', 'parallel (opposite direction)' or 'neither', from the angle. |
Example
a = (1, 2, 3), b = (4, 5, 6): {"vector_a":[1,2,3],"vector_b":[4,5,6]} → {"dot_product":32,"cross_product":[-3,6,-3],"cross_product_magnitude":7.348469,"magnitude_a":3.741657,"magnitude_b":8.774964,"angle_degrees":12.9332,"unit_vector_a":[0.267261,0.534522,0.801784],"scalar_projection":3.646738,"vector_projection":[1.662338,2.077922,2.493506],"sum":[5,7,9],"difference":[-3,-3,-3],"relationship":"neither"}
a = (3, 4), b = (4, −3): {"vector_a":[3,4],"vector_b":[4,-3]} → {"dot_product":0,"cross_product":[0,0,-25],"magnitude_a":5,"magnitude_b":5,"angle_degrees":90,"unit_vector_a":[0.6,0.8],"scalar_projection":0,"vector_projection":[0,0],"relationship":"perpendicular"}
GET https://tttkmbb.com/api/v1/calculate/vector-operations?vector_a=1%2C2%2C3&vector_b=4%2C5%2C6
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/vector-operations(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/vector-operations · Markdown: https://tttkmbb.com/math/vector-operations.md · JSON definition: https://tttkmbb.com/math/vector-operations.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="vector-operations" - OpenAPI operationId:
calculate_vector_operations - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Dot product (reference)
- Wikipedia – Cross product (reference)
- Wikipedia – Vector projection (reference)
FAQ
Is the cross product defined in 2D?
Not as a vector; the calculator embeds 2D vectors in the xy-plane and returns (0, 0, a₁b₂ − a₂b₁), whose third component is the signed area of the parallelogram they span.
Why is the angle between 0° and 180°?
The angle from the dot product is the unsigned angle between the directions; 0° means the same direction, 90° perpendicular and 180° opposite.
Related calculators
- 3D Distance Calculator — Distance and direction cosines between two points in space.
- Matrix Determinant Calculator — The cross product is the determinant of a 3×3 matrix.
- Angle Converter — Convert the angle between degrees, radians and gradians.