What are vectors?
A vector is a quantity with both magnitude and direction: force, velocity, acceleration, momentum, electric and magnetic fields, angular momentum. By contrast a scalar is just a number: mass, time, energy, temperature. Geometrically a vector is drawn as an arrow whose length is the magnitude and whose angle gives the direction; algebraically it is an ordered list of components, two in the plane and three in space. Six operations cover almost everything you do with vectors: magnitude |A| = √(Ax² + Ay² + Az²), addition component-by-component, dot product A·B = ΣAiBi, cross product A×B (3D only), angle from cosθ = A·B/(|A||B|), and unit vector / projection. The panel implements all six in 2D and 3D with an immediate Canvas plot for visualization — seeing two arrows and their sum or product is the difference between abstract manipulation and physical intuition.
Three products do everything you need: the dot product (a scalar measuring alignment, A·B = |A||B|cosθ), the cross product (a vector perpendicular to both inputs, magnitude |A||B|sinθ), and the projection operator (component of A along a chosen direction). They are the bookkeeping of every physics formula that involves more than one vector.
Magnitude and the 2D canonical example
The 3-4-5 right triangle is the canonical example for 2D vectors. Take A = (3, 4). Its magnitude is |A| = √(3² + 4²) = √25 = 5. Its direction from the +x axis is arctan(4/3) ≈ 53.13°. Any 2D vector can be written as a magnitude times a unit vector pointing in that direction: A = 5·(0.6, 0.8). The decomposition panel accepts a magnitude and angles θ and φ and returns the x, y, z components under either spherical convention (x = r cosθ cosφ, y = r cosθ sinφ, z = r sinθ) or planar (with φ ignored, x = r cosθ, y = r sinθ). For r = 10, θ = 36.87° in 2D mode this returns (8, 6, 0) — the 6-8-10 right triangle, scaled from the original 3-4-5. Recognizing these integer triangles is the shortcut for spotting which components are perpendicular without invoking trigonometry.
Dot product — scalar measure of alignment
For two vectors A and B, the dot product A·B = AxBx + AyBy (+ AzBz) is a scalar equal to |A||B|cosθ — that is, the product of magnitudes times the cosine of the angle between them. The default 2D sample (A = (3, 4), B = (5, 2)) gives A·B = 15 + 8 = 23, magnitudes |A| = 5 and |B| = √29 ≈ 5.385, and angle cosθ = 23/(5 × 5.385) = 23/26.93 ≈ 0.854, so θ ≈ 31.33°. Three sign consequences carry all the interpretation: cosθ > 0 means the angle is acute and the vectors point generally the same way; cosθ < 0 means obtuse and the vectors oppose; cosθ = 0 means perpendicular. Dot product is the work done by a force F along a displacement d (W = F·d), and the cosine is why pushing at an angle is less effective than pushing along the line of motion.
Cross product — vector perpendicular to both inputs
The cross product is a 3D-only operation whose result is a vector perpendicular to both inputs, with magnitude |A||B|sinθ and direction set by the right-hand rule (point index finger along A, middle finger along B, thumb gives A×B). In components, A×B = (AyBz − AzBy, AzBx − AxBz, AxBy − AyBx). The default 3D sample (A = (2, 3, 4), B = (5, 1, 2)) yields A×B = (3·2 − 4·1, 4·5 − 2·2, 2·1 − 3·5) = (2, 16, −13). The cross product is antisymmetric: B×A = −A×B, so swapping the inputs flips the sign. Three physics appearances: torque τ = r×F (rotational force), angular momentum L = r×p (orbital angular momentum), and magnetic force F = qv×B on a moving charge. The magnitude |A×B| equals the area of the parallelogram the two vectors span, which is why cross-product results always describe area or rotation. Torque is the cross product at work: τ = r×F has magnitude |r||F|sinθ, so pushing through the pivot gives zero and a longer wrench gives more.
Angle between vectors
Once you have the dot product and magnitudes, the angle is one arc-cosine: cosθ = A·B/(|A||B|), with θ in [0, π]. A small dot product relative to the magnitudes means nearly perpendicular vectors; a dot product equal to |A||B| means the vectors point the same way (θ = 0); a dot product equal to −|A||B| means opposite (θ = π). The formula is the same in 2D and 3D — only the dimension of the component sums differs. Geometrically, the dot product can be viewed as projecting A onto B (or B onto A), multiplying by the magnitude of the other, so the cosine is literally the projection ratio.
Unit vector and projection
A unit vector is a vector with magnitude 1, pointing in the same direction as the original: u = A / |A|. Unit vectors are how you describe "pure direction"; the i, j, k basis vectors of Cartesian coordinates are the canonical examples, and any direction in 3D can be written as a linear combination of them. The projection of A onto B (or the component of A along B) is projBA = (A·B / |B|²) · B — the part of A that lies along B. The scalar version (A·B/|B|) is the signed length of that projection. This is what makes dot product the work formula: the displacement component along the force, times the force magnitude, is the work done.
Misconceptions
- The dot product is multiplication of vectors. It is the scalar product — produces a number, not a vector. Similarly the cross product is the vector product. Calling them "multiplication" hides that they have completely different outputs.
- The cross product is a scalar. In 2D the perpendicular component is sometimes called a scalar (the determinant axby − aybx), but in 3D the cross product is genuinely a vector. The magnitude and the direction are both physically meaningful.
- Cross product is commutative. It is anti-commutative: A×B = −B×A. The order matters — torque r×F is in the opposite sense from F×r.
- A vector has a fixed location. Vectors are free — you can slide them around the page without changing them. What is fixed is their magnitude and direction; only specific vectors in physics (position vectors, electric field at a point) are tied to a location.
Related tools: Mechanics for torque, work, and angular momentum in context, Rotational Dynamics for how the cross product builds angular momentum, and Circuits for the magnetic force F = qv×B.