# 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.

- Calculator id: `vector-operations` · Category: Math (`math`) · Tool name: `calculate_vector_operations`
- Canonical page: https://tttkmbb.com/math/vector-operations · This document: https://tttkmbb.com/math/vector-operations.md · JSON definition: https://tttkmbb.com/math/vector-operations.json

## Purpose

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.

**Use when:** 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.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `vector_a` | number_list |  | required | Components of the first vector, 2 or 3 numbers (e.g. 1, 2, 3). |
| `vector_b` | number_list |  | required | Components of the second vector, with the same number of components as vector_a. |

## Output

| Field | 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. |

## 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.

## Data Sources

- Wikipedia – Dot product — https://en.wikipedia.org/wiki/Dot_product (reference, retrieved 2026-09-24)
- Wikipedia – Cross product — https://en.wikipedia.org/wiki/Cross_product (reference, retrieved 2026-09-24)
- Wikipedia – Vector projection — https://en.wikipedia.org/wiki/Vector_projection (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/vector-operations?vector_a=…&vector_b=…`
- `POST https://tttkmbb.com/api/v1/calculate/vector-operations` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/vector-operations · OpenAPI operationId `calculate_vector_operations` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "vector-operations", "inputs": {…}}`

## Example

- a = (1, 2, 3), b = (4, 5, 6): inputs `{"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): inputs `{"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
```

## Limitations

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. 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. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [3D Distance Calculator](https://tttkmbb.com/math/distance-3d.md) — Distance and direction cosines between two points in space.
- [Matrix Determinant Calculator](https://tttkmbb.com/math/matrix-determinant.md) — The cross product is the determinant of a 3×3 matrix.
- [Angle Converter](https://tttkmbb.com/conversion/angle.md) — Convert the angle between degrees, radians and gradians.
