Loading content...
The cross product (also called the vector product) is a fundamental binary operation on two vectors in three-dimensional Euclidean space. Unlike the dot product which yields a scalar, the cross product produces a new vector that is perpendicular to both original vectors and whose direction follows the right-hand rule.
Given two 3D vectors a = [a₁, a₂, a₃] and b = [b₁, b₂, b₃], their cross product a × b results in a vector c = [c₁, c₂, c₃] computed using the following formulas:
$$c_1 = a_2 \cdot b_3 - a_3 \cdot b_2$$ $$c_2 = a_3 \cdot b_1 - a_1 \cdot b_3$$ $$c_3 = a_1 \cdot b_2 - a_2 \cdot b_1$$
Key Properties of Cross Products:
This operation is ubiquitous in physics for computing torque and angular momentum, in computer graphics for determining surface normals, and in engineering for analyzing mechanical systems.
Your Task: Implement a function that takes two 3-dimensional vectors and returns their cross product as a new vector following the mathematical definition above.
a = [1, 0, 0]
b = [0, 1, 0][0, 0, 1]The input vectors are the standard unit vectors along the x-axis (î) and y-axis (ĵ). Applying the cross product formula:
• c₁ = (0 × 0) - (0 × 1) = 0 • c₂ = (0 × 0) - (1 × 0) = 0 • c₃ = (1 × 1) - (0 × 0) = 1
The result [0, 0, 1] is the unit vector along the z-axis (k̂), demonstrating the right-hand rule: curling fingers from î to ĵ points the thumb in the +z direction.
a = [0, 1, 0]
b = [0, 0, 1][1, 0, 0]These are the unit vectors along the y-axis (ĵ) and z-axis (k̂). Computing the cross product:
• c₁ = (1 × 1) - (0 × 0) = 1 • c₂ = (0 × 0) - (0 × 1) = 0 • c₃ = (0 × 0) - (1 × 0) = 0
The result [1, 0, 0] is the unit vector along the x-axis (î), following the cyclic pattern ĵ × k̂ = î.
a = [1, 2, 3]
b = [4, 5, 6][-3, 6, -3]For general vectors, apply the cross product formula component by component:
• c₁ = (2 × 6) - (3 × 5) = 12 - 15 = -3 • c₂ = (3 × 4) - (1 × 6) = 12 - 6 = 6 • c₃ = (1 × 5) - (2 × 4) = 5 - 8 = -3
The resulting vector [-3, 6, -3] is perpendicular to both [1, 2, 3] and [4, 5, 6]. This can be verified by checking that the dot product with each input vector equals zero.
Constraints