Vector Magnitude Calculator Formula
Understand the math behind the vector magnitude calculator. Each variable explained with a worked example.
Formulas Used
Magnitude
magnitude = magUnit X
unit_x = mag != 0 ? x / mag : 0Unit Y
unit_y = mag != 0 ? y / mag : 0Unit Z
unit_z = mag != 0 ? z / mag : 0Direction Deg
direction_deg = atan(y / (x != 0 ? x : 0.0001)) * 180 / piVariables
| Variable | Description | Default |
|---|---|---|
x | x component | 3 |
y | y component | 4 |
z | z component (0 for 2D) | 0 |
mag | Derived value= sqrt(pow(x,2) + pow(y,2) + pow(z,2)) | calculated |
How It Works
Vector Magnitude
Formula
|v| = sqrt(x² + y² + z²)
For 2D vectors (z = 0): |v| = sqrt(x² + y²)
Unit Vector
A unit vector has magnitude 1 and points in the same direction:
v_hat = v / |v| = (x/|v|, y/|v|, z/|v|)
Direction (2D)
The angle from the positive x-axis: theta = arctan(y/x)
Worked Example
Find the magnitude and unit vector of (3, 4, 0).
x = 3y = 4z = 0
- 01|v| = √(9 + 16 + 0) = √25 = 5
- 02Unit vector = (3/5, 4/5, 0) = (0.6, 0.8, 0)
- 03Direction = arctan(4/3) ≈ 53.13°
Ready to run the numbers?
Open Vector Magnitude Calculator