Leave z-component empty for 2D vectors. For cross product, z defaults to 0 if empty.
A vector is a mathematical object that has both magnitude (size) and direction. Vectors are represented as ordered lists of numbers, typically written as (x, y) for 2D or (x, y, z) for 3D. They are fundamental in physics, engineering, computer graphics, and many other fields.
Add corresponding components:
A + B = (a1 + b1, a2 + b2, a3 + b3)
Subtract corresponding components:
A - B = (a1 - b1, a2 - b2, a3 - b3)
Multiply corresponding components and sum:
A . B = a1*b1 + a2*b2 + a3*b3
The result is a scalar (single number). It equals |A||B|cos(theta) where theta is the angle between vectors.
Produces a vector perpendicular to both inputs:
A x B = (a2*b3 - a3*b2, a3*b1 - a1*b3, a1*b2 - a2*b1)
The magnitude equals |A||B|sin(theta).
The length of a vector:
|A| = sqrt(a1^2 + a2^2 + a3^2)
Using the dot product relationship:
theta = arccos((A . B) / (|A| * |B|))
A = (3, 4, 2) and B = (1, -2, 5)
A + B = (3+1, 4+(-2), 2+5) = (4, 2, 7)
A = (2, 3) and B = (4, -1)
A . B = 2*4 + 3*(-1) = 8 - 3 = 5
A = (1, 2, 3) and B = (4, 5, 6)
A x B = (2*6 - 3*5, 3*4 - 1*6, 1*5 - 2*4)
= (12 - 15, 12 - 6, 5 - 8)
= (-3, 6, -3)
Vectors describe forces, velocities, accelerations, and other physical quantities with direction.
3D modeling, lighting calculations, collision detection, and animations all rely heavily on vector mathematics.
Structural analysis, fluid dynamics, and electromagnetic field calculations use vectors extensively.
Feature vectors, word embeddings, and neural network operations are all based on vector mathematics.