Understanding Vector Representations
A vector is defined by two properties: magnitude (its length) and direction (the angle it makes relative to a reference axis). In practice, there are two main ways to describe a vector:
- Cartesian coordinates: Express a vector as an ordered list of component values. In 2D, a vector is
[ax, ay]; in 3D, it becomes[ax, ay, az]. Each component represents displacement along that axis. - Magnitude and direction: Specify the vector's length and the angle
θit makes with the horizontal axis. For 2D vectors, you can convert between these formats using trigonometry.
The choice of representation depends on your data. If you know the endpoint coordinates, use Cartesian form. If you've measured the vector's length and angle, use magnitude-direction notation.
Converting Between Coordinate Systems
When working with 2D vectors in polar form (magnitude and direction), convert to Cartesian components using these relationships:
ax = m × cos(θ)
ay = m × sin(θ)
m— Magnitude (length) of the vectorθ— Direction angle measured counterclockwise from the positive x-axisa<sub>x</sub>, a<sub>y</sub>— Cartesian components of the vector
Core Vector Operations
Addition: Combine two vectors by adding their corresponding components. For a = [ax, ay] and b = [bx, by], the sum is [ax + bx, ay + by]. Geometrically, place the tail of b at the head of a; the resultant vector stretches from the origin to the final point.
Subtraction: Find a − b by subtracting each component of b from the corresponding component of a. This is equivalent to adding the vector −b to a.
Dot product (scalar product): Multiply corresponding components and sum them: a · b = axbx + ayby + azbz. The result is a scalar (single number), not a vector. The dot product reveals the angle between vectors and is used in projection calculations.
Cross product: Available in 3D only. This operation yields a new vector perpendicular to both input vectors. The magnitude of a × b equals |a| × |b| × sin(θ), where θ is the angle between them.
Vector Magnitude, Normalization, and Projection
Magnitude (norm): The length of a vector is found using the Pythagorean theorem. For vector a = [ax, ay, az], the magnitude is |a| = √(ax² + ay² + az²).
Normalization: Scale a vector to unit length (magnitude 1) while preserving its direction. Divide each component by the vector's magnitude: [ax/|a|, ay/|a|, az/|a|]. Normalized vectors are useful as direction indicators in physics and computer graphics.
Projection: Find how much of vector a points in the direction of vector b. The scalar projection magnitude is (a · b) / |b|. To get the vector projection, scale vector b by this factor. Projections appear frequently in work calculations, shadow analysis, and decomposing forces into components.
Common Pitfalls and Practical Considerations
Keep these points in mind when working with vector calculations:
- Order matters for cross products — Unlike addition, the cross product is not commutative. <code>a × b</code> and <code>b × a</code> point in opposite directions. If you depend on the direction result, verify which vector order you need.
- Angle interpretation in 2D — When entering direction angles, ensure you're measuring from the correct reference (usually the positive x-axis) and in the correct direction (counterclockwise is standard). Small angle errors compound when performing multiple operations.
- Zero vectors and edge cases — A vector with all zero components causes issues: its magnitude is zero, it cannot be normalized, and its direction is undefined. Always validate that input vectors are non-zero before normalizing or computing angles between them.
- Numerical precision in 3D — Cross product and projection calculations in 3D involve more arithmetic steps, which can accumulate floating-point rounding errors. For critical engineering work, consider the precision limits of your tools.